#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> c(N, -1);
  for (int i = 0; i < M; i++) {
    int s, t;
    cin >> s >> t;
    s--;
    if (c[s] == -1 || c[s] == t) {
      c[s] = t;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (N == 1 && c[0] == 0) {
    cout << 0 << endl;
  } else {
    if (c[0] == 0) {
      cout << -1 << endl;
    } else {
      bool p = false;
      for (int i = 0; i < N; i++) {
        if (c[i] != -1) {
          cout << c[i];
          p = true;
        } else {
          if (p)
            cout << 0;
          else {
            cout << 1;
            p = true;
          }
        }
      }
      cout << endl;
    }
  }
  return 0;
}
