#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]--;
    }
    if (m == 0)
      cout << "-1\n";
    else {
      int mul = pow(10, n);
      int mul2 = pow(10, n - 1);
      bool sw2 = false;
      int w[100];
      for (int i = mul2; i < mul; i++) {
        string cad = to_string(i);
        bool sw = true;
        memset(w, 0, sizeof w);
        for (int j = 0; j < m; j++) {
          if (cad[s[j]] != c[j]) {
            sw = false;
          } else {
            w[s[j]] = 1;
          }
        }
        if (sw and w[0] != 0) {
          cout << cad << "\n";
          sw2 = true;
          break;
        }
      }
      if (!sw2) cout << "-1\n";
    }
  }
  return 0;
}
