#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m], c[m];
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  int p[] = {1, 10, 100, 1000};
  int lb = p[n - 1], ub = p[n];
  for (int x = lb; x < ub; x++) {
    bool ok = true;
    string t = to_string(x);
    for (int i = 0; i < m; i++)
      if (t[s[i] - 1] != c[i] + '0') {
        ok = false;
        break;
      }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << "-1\n";
}
