#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long a[n + 1];
  memset(a, -1, sizeof a);
  long long flag = 0;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    if (a[x] != -1 and a[x] != y) {
      flag = -1;
    }
    a[x] = y;
  }
  if (flag == -1 or a[1] == 0) {
    cout << -1;
  } else {
    for (long long i = 1; i <= n; i++) {
      if (a[i] == -1) {
        if (i == 1)
          a[i] = 1;
        else
          a[i] = 0;
      }
      cout << a[i];
    }
  }
  return 0;
}
