#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (cin >> n >> m) {
    char c[100];
    int s[100];
    memset(c, 0, sizeof c);
    memset(s, 0, sizeof s);
    for (int i = 0; i < m; i++) {
      cin >> s[i] >> c[i];
      s[i]--;
    }
    int mul = pow(10, n) - 1;
    bool sw2 = false;
    for (int i = 100; i <= mul; i++) {
      string cad = to_string(i);
      bool sw = true;
      for (int j = 0; j < m; j++) {
        if (cad[s[j]] != c[j]) {
          sw = false;
        }
      }
      if (sw) {
        cout << cad << "\n";
        sw2 = true;
        break;
      }
    }
    if (!sw2) cout << "-1\n";
  }
  return 0;
}
