#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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 a[n];
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    int ok = 1;
    int tmp = i;
    for (int i = 0; i < n; i++) {
      a[i] = tmp % 10;
      tmp /= 10;
    }
    for (int j = 0; j < m; j++) {
      if (a[n - s[j]] != c[j]) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
