#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  map<long long, long long> mp;
  for (long long i = 1; i <= 5; i++) mp[i] = -1;
  bool ch = true;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    if (mp[x] == -1 || mp[x] == y)
      mp[x] = y;
    else {
      ch = false;
    }
    if (x == 1 && y == 0) ch = false;
    if (x > n) ch = false;
  }
  if (ch) {
    string ss = "";
    bool chh = true, ttt = true;
    ;
    for (long long i = 1; i <= n; i++) {
      if (mp[i] == -1)
        ss.push_back('1');
      else {
        ss.push_back('0' + mp[i]);
      }
      chh = false;
    }
    cout << ss;
  } else
    cout << -1;
  return 0;
}
