#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  bool flag = false;
  cin >> n >> m;
  vector<int> s(m);
  vector<char> c(m);
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  int p = 0;
  if (n > 1) p = pow(10, n - 1);
  for (int i = p; i < pow(10, n); i++) {
    string j = to_string(i);
    for (int di = 0; di < m; di++) {
      if (j[s[di] - 1] != c[di]) break;
      if (di == m - 1) {
        cout << i << endl;
        return 0;
      }
    }
  }
  if (m == 0)
    cout << pow(10, n - 1) << endl;
  else if (!flag)
    cout << "-1" << endl;
  return 0;
}
