#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  bool flag = true;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (mp.find(x) != mp.end()) {
      if (mp[x] != y) flag = false;
      continue;
    }
    if (x > n) {
      flag = false;
      continue;
    }
    mp.insert(make_pair(x, y));
  }
  if (flag) {
    if (mp[1] == 0 && n != 1) {
      cout << -1 << endl;
    } else {
      if (mp.find(1) == mp.end()) {
        mp.insert(make_pair(1, 1));
      }
      for (int i = 1; i <= n; i++) {
        if (mp.find(i) == mp.end()) {
          mp[i] = 0;
        }
        cout << mp[i];
        if (i == n) {
          cout << endl;
        }
      }
    }
  } else {
    cout << -1 << endl;
  }
}
