#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = -1;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = (pow(10, n - 1) - 1); i < (pow(10, n)); i++) {
    for (int j = 0; j < (int)(m); j++) {
      if (i != 0 && int((i / (pow(10, n - s[j])))) % 10 != c[j]) {
        break;
      } else if (i == 0 && i != c[j]) {
        break;
      } else if (j == m - 1) {
        ans = i;
      }
    }
    if (ans != -1) {
      break;
    }
  }
  cout << ans << endl;
}
