#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 4e5 + 10;
void raushan_kumar() {
  long long n, m;
  cin >> n >> m;
  long long a[n + 1];
  for (long long i = 1, iend = n; i <= iend; i++) {
    a[i] = 1;
  }
  long long used[n + 1];
  memset(used, -1, sizeof(used));
  set<pair<long long, long long>> s;
  long long flag = 0;
  for (long long i = 1, iend = m; i <= iend; i++) {
    long long l, x;
    cin >> l >> x;
    if (used[l] == -1 or a[l] == x) {
      a[l] = x;
      used[l] = 1;
    } else {
      flag = 1;
    }
  }
  long long pos = 0;
  for (long long i = 1; i <= n; i++) {
    if (used[i] == -1) {
      pos = i;
      break;
    }
  }
  for (long long i = pos; i <= n; i++) {
    if (used[i] == -1) {
      a[i] = 0;
    }
  }
  if (flag)
    cout << -1;
  else if (n > 1 and a[1] == 0) {
    cout << -1;
  } else {
    for (long long i = 1, iend = n; i <= iend; i++) {
      cout << a[i];
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    raushan_kumar();
  }
}
