#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
int main() {
  bool f = true;
  int N, M;
  cin >> N >> M;
  vi a(N, -1);
  for (int i = 0; i < (int)(M); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (c == 0) {
      if (s == N - 1) {
        if (a.at(s) == -1) {
          a.at(s) = 0;
        } else if (a.at(s) != 0) {
          f = false;
        }
      } else {
        f = false;
      }
    } else {
      if (a.at(s) == -1) {
        a.at(s) = c;
      } else if (a.at(s) != c) {
        f = false;
      }
    }
  }
  if (!f) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < (int)(N); i++) {
      if (a.at(i) == -1) {
        if (i == 0) {
          cout << 1;
        } else {
          cout << 0;
        }
      } else {
        cout << a.at(i);
      }
    }
    cout << endl;
  }
}
