#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[M], c[M];
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < 999; i++) {
    int Ni;
    if (i > 99) {
      Ni = 3;
    } else if (i > 9) {
      Ni = 2;
    }
    if (Ni != N) continue;
    bool flag = true;
    for (int j = 0; j < M; j++) {
      int tmp = (int)pow(10, N - s[j]);
      int tmp2 = i / (tmp);
      tmp2 = tmp2 % 10;
      if (c[j] != tmp2) {
        flag = false;
      }
    }
    if (flag) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
