#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    a[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    int enta, entb;
    cin >> enta >> entb;
    if (a[enta - 1] == -1) {
      a[enta - 1] = entb;
    } else if (a[enta - 1] != entb) {
      cout << -1 << endl;
      return 0;
    }
    if (n != 1 && enta == 1 && entb == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if ((a[i] == -1 && i != 0) || (a[i] == -1 && i == 0 && m == 0))
      a[i] = 0;
    else if (a[i] == -1 && i == 0)
      a[i] = 1;
    cout << a[i];
  }
  cout << endl;
  return 0;
}
