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