#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> a;
  bool can = true;
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    if (a.count(s) && a[s] != c) {
      can = false;
      break;
    } else
      a[s] = c;
  }
  if (a.count(1) && a[1] == 0 && n != 1) can = false;
  vector<int> ans(n);
  if (a.size() > n) can = false;
  if (!can)
    cout << -1 << endl;
  else if (n == 1 && can == true)
    cout << 0 << endl;
  else if (can == true) {
    if (a.count(1))
      ans[0] = a[1];
    else
      ans[0] = 1;
    for (int i = 1; i < (int)(n); i++) {
      if (a.count(i + 1))
        ans[i] = a[i + 1];
      else
        ans[i] = 0;
    }
    for (int i = 0; i < (int)(n); i++) cout << ans[i];
    cout << endl;
  }
}
