#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long arr[n];
  for (long long i = 0; i <= n; i++) {
    arr[i] = -1;
  }
  bool hbe = true;
  for (long long i = 0; i < m; i++) {
    long long k, l;
    cin >> k >> l;
    if ((arr[k - 1] != -1 && arr[k - 1] != l) || m > n) {
      hbe = false;
    } else {
      arr[k - 1] = l;
    }
    if (k == 1 && l == 0) {
      hbe = false;
    }
  }
  if (!hbe) {
    cout << -1 << endl;
    return 0;
  }
  bool z = false;
  long long ans[n];
  for (long long i = 0; i < n; i++) {
    if (arr[i] == -1 && !z) arr[i] = 1;
    if (arr[i] == -1 && z) arr[i] = 0;
    if (arr[i] > 0) {
      z = true;
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << arr[i];
  }
  cout << endl;
}
