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