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