#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 3;
int a[5], n, m, p, d;
int main() {
  memset(a, -1, sizeof(a));
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p >> d;
    p--;
    if (a[p] != -1) {
      printf("-1\n");
      return 0;
    }
    a[p] = d;
  }
  if (a[0] == 0 && n > 1) {
    printf("-1\n");
    return 0;
  }
  if (a[0] == -1) a[0] = 1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) a[i] = 0;
    ans = ans * 10 + a[i];
  }
  cout << ans << endl;
  return 0;
}
