#include <bits/stdc++.h>
using namespace std;
long long inf = LLONG_MAX;
long double pi = M_PI;
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> s(m), c(m);
  for (long long i = 0; i < m; i++) cin >> s[i] >> c[i];
  vector<long long> ans(n, -1);
  for (long long i = 0; i < m; i++) {
    if (ans[s[i] - 1] == -1)
      ans[s[i] - 1] = c[i];
    else if (ans[s[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (ans[i] == -1) {
      if (i == 0)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  if (ans[0] == 0)
    cout << -1 << endl;
  else {
    for (long long i = 0; i < n; i++) cout << ans[i];
    cout << endl;
  }
}
