#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  bool ans = true;
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n, -1);
  for (long long(i) = 0; (i) < (long long)(m); (i)++) {
    long long s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) ans = false;
    if (v[s] == c)
      continue;
    else if (v[s] == -1)
      v[s] = c;
    else
      ans = false;
  }
  if (not ans)
    cout << -1 << endl;
  else {
    for (long long(i) = 0; (i) < (long long)(n); (i)++) {
      if (v[i] == -1) {
        if (i == 0)
          v[i] = 1;
        else
          v[i] = 0;
      }
    }
    for (long long(i) = 0; (i) < (long long)(n); (i)++) {
      cout << v[i];
    }
    cout << endl;
  }
}
