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