#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
  }
  int min = 0;
  if ((N == 2) || (N == 3)) {
    min = pow(10, N - 1);
  }
  if (M == 0) {
    cout << min << endl;
    return 0;
  }
  for (int n = 0; n < 1000; n++) {
    bool through = true;
    for (int i = 0; i < M; i++) {
      if (s[i] == 1) {
        if (n / 100 != c[i]) {
          through = false;
          break;
        }
      } else if (s[i] == 2) {
        if ((n / 10) % 10 != c[i]) {
          through = false;
          break;
        }
      } else {
        if (n % 10 != c[i]) {
          through = false;
          break;
        }
      }
    }
    if (through) {
      if (n >= pow(10, N - 1)) {
        cout << n << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}
