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