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