#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  string res(N, '?');
  bool ok = true;
  for (int i = 0; i < M; ++i) {
    int s, c;
    cin >> s >> c;
    --s;
    if (res[s] != '?' && res[s] != '0' + c) {
      ok = false;
    } else {
      res[s] = '0' + c;
    }
  }
  if (N > 1 && res[0] == '0') {
    ok = false;
  }
  if (!ok) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < N; ++i) {
      if (res[i] == '?') {
        if (i == 0) {
          res[i] = '1';
        } else {
          res[i] = '0';
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}
