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