#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m, f = 1;
  cin >> n >> m;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    a[i] = -1;
  }
  for (long long i = 0; i < m; i++) {
    long long s, c;
    cin >> s >> c;
    if (a[s - 1] == -1 || a[s - 1] == c) {
      a[s - 1] = c;
    } else {
      f = -1;
    }
  }
  if (f == -1) {
    cout << -1;
    return 0;
  }
  if (a[0] == 0 && n != 1) {
    cout << -1;
    return 0;
  }
  if (a[0] == -1 && n != 1) {
    a[0] = 1;
  } else {
    a[0] = 0;
  }
  cout << a[0];
  for (long long i = 1; i < n; i++) {
    if (a[i] == -1) {
      a[i] = 0;
    }
    cout << a[i];
  }
}
