#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m;
  string s, ans;
  char t, u = '1', v = '0';
  for (int i = 0; i < n; i++) {
    ans += '#';
  }
  for (int i = 0; i < m; i++) {
    cin >> k >> t;
    if (ans[k - 1] == '#' || ans[k - 1] == t) {
      ans[k - 1] = t;
      if (k == 1 && t == '0') {
        ans = "-1";
      }
    } else if (ans[k - 1] != t) {
      ans = "-1";
      break;
    }
  }
  if (ans != "-1") {
    for (int i = 0; i < n; i++) {
      if (ans[i] == '#') {
        ans[i] = v;
      }
    }
  }
  if (n != 1 && ans[0] == v) {
    ans.replace(0, 1, "1");
  }
  cout << ans << endl;
  return 0;
}
