#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int numbs[n];
  for (int i = 0; i < n; i++) {
    numbs[i] = -1;
  }
  int idx, numb;
  bool state = true;
  for (int i = 0; i < m; i++) {
    cin >> idx >> numb;
    if (numbs[idx - 1] != numb && numbs[idx - 1] != -1) {
      state = false;
      break;
    }
    numbs[idx - 1] = numb;
  }
  if (numbs[0] == 0) {
    state = false;
  }
  if (state == true) {
    for (int i = 0; i < n; i++) {
      if (numbs[i] == -1) {
        if (i == 0) {
          numbs[i] = 1;
        } else {
          numbs[i] = 0;
        }
      }
      cout << numbs[i];
    }
    cout << endl;
  }
  if (state == false) {
    cout << -1 << endl;
  }
}
