#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n, m;
  cin >> n >> m;
  long long int an[n];
  long long int ann[n];
  an[0] = 1;
  for (long long int i = 1; i < n; i++) {
    an[i] = 0;
  }
  for (long long int i = 0; i < n; i++) {
    ann[i] = 0;
  }
  long long int a[m][2];
  for (long long int i = 0; i < m; i++) {
    cin >> a[i][0] >> a[i][1];
    a[i][0]--;
  }
  for (long long int i = 0; i < m; i++) {
    if (ann[a[i][0]] && (an[a[i][0]] != a[i][1])) {
      cout << -1 << endl;
      return 0;
    }
    an[a[i][0]] = a[i][1];
    ann[a[i][0]] = 1;
  }
  long long int buf = 0;
  for (long long int i = 0; i < n; i++) {
    if (an[i] == 0) {
      buf++;
    }
    if (buf == n) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (long long int i = 0; i < n; i++) {
    cout << an[i];
  }
  cout << endl;
}
