#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1 && m == 0) {
    cout << 0 << endl;
    return 0;
  }
  int v[m][2];
  for (int i = 0; i < m; i++) {
    cin >> v[i][0] >> v[i][1];
  }
  int ans = -1;
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    string t = to_string(i);
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int s = v[j][0] - 1;
      char c = v[j][1] + '0';
      if (t[s] != c) ok = false;
    }
    if (ok) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}
