#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> a(N, 100);
  for (long long i = 0; i < M; i++) {
    long long s, c;
    cin >> s >> c;
    if (a[N - s] == 100) {
      a[N - s] = c;
    } else if (a[N - s] == c) {
      continue;
    } else {
      cout << -1 << endl;
      return 0;
    }
    if (s == 1 && c == 0) {
      if (N > 1) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (long long i = N - 1; i >= 0; i--) {
    if (a[i] != 100) {
      cout << a[i];
    } else {
      if (i == N - 1) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
  }
  cout << endl;
  return 0;
}
