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