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