#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  bool f = 0;
  for (int i = 0; i < m; i++) {
    int si, ci;
    cin >> si >> ci;
    if (mp.count(si)) {
      if (mp[si] != ci) {
        f = 1;
      }
    }
    mp[si] = ci;
  }
  if (mp.count(1)) {
    if (mp[1] == 0) {
      f = 1;
    }
  } else {
    if (n == 1)
      mp[1] = 0;
    else
      mp[1] = 1;
  }
  if (f == 1) {
    cout << "-1"
         << "\n";
  } else {
    for (int i = 1; i <= n; i++) {
      cout << mp[i];
    }
  }
  return 0;
}
