#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T itr1, T itr2) {
  auto now = itr1;
  while (now < itr2) {
    cout << *now << " ";
    now++;
  }
  cout << endl;
}
const long long MOD = pow(10, 9) + 7;
const long long LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for (int i = (int)0; i < (int)M; i++) {
    cin >> s[i] >> c[i];
  }
  int res = -1;
  for (int n = (int)pow(10, N - 1); n < (int)pow(10, N); n++) {
    string n_str = to_string(n);
    bool flg = true;
    for (int i = (int)0; i < (int)M; i++) {
      if (n_str[s[i] - 1] != '0' + c[i]) flg = false;
    }
    if (flg) {
      res = n;
      break;
    }
  }
  cout << res << endl;
  return 0;
}
