#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> ret(n, -1);
  bool check = true;
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ret[s] == -1) {
      ret[s] = c;
    } else if (ret[s] != c) {
      check = false;
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    if (ret[i] == -1) {
      if (i == 0)
        ret[i] = 1;
      else
        ret[i] = 0;
    }
  }
  if (ret[0] == 0 && n != 1) check = false;
  if (check) {
    for (int i = 0; i < (int)(n); i++) cout << ret[i];
    cout << endl;
  } else {
    cout << -1 << endl;
  }
}
