#include <bits/stdc++.h>
using namespace std;
int a[105], b[105], f[105], ans = 99999999;
int main() {
  cout << -1;
  return 0;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    if (f[a[i]] && f[a[i]] != b[i]) {
      cout << -1;
      return 0;
    }
    f[a[i]] = b[i];
  }
  for (int i = pow(10, n - 1); i <= pow(10, n) - 1; i++) {
    for (int j = 1; j <= m; j++) {
      int q = int(i / pow(10, n - a[j])) % 10;
      if (q != b[j]) goto loop;
    }
    ans = min(i, ans);
  loop:;
  }
  if (ans != 99999999)
    cout << ans;
  else
    cout << -1;
}
