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