#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  string res = "-1";
  vector<int> s(M);
  vector<char> c(M);
  for (int i = 0; i < M; i++) cin >> s[i] >> c[i];
  int base = pow(10, N - 1);
  for (int i = base; i < base * 10; i++) {
    string str_digit = to_string(i);
    for (int j = 0; j < M; j++) {
      if (str_digit[s[j] - 1] != c[j]) break;
      if (j == M - 1) res = str_digit;
    }
    if (res != "-1") break;
  }
  cout << res;
  return 0;
}
