#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int m;
  cin >> n;
  cin >> m;
  vector<int> a(n, -1);
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (a[s - 1] < 0) {
      a[s - 1] = c;
    } else {
      if (a[s - 1] != c) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (a[0] == -1) {
    a[0] = 1;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] < 0) {
      a[i] = 0;
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    cout << a[i];
  }
  cout << endl;
  return 0;
}
