#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> digitos;
  map<int, int> check;
  int n, m, s, c;
  cin >> n >> m;
  digitos.resize(n);
  digitos[0] = 3;
  for (int i = 1; i <= m; i++) {
    cin >> s >> c;
    if (check.find(s) != check.end()) {
      if (check[s] != c) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      digitos[s - 1] = c;
      check.insert(make_pair(s, c));
    }
  }
  if (digitos[0] <= 0) {
    cout << -1 << endl;
    return 0;
  } else
    for (int i = 0; i < n; i++) {
      if (check.find(i + 1) == check.end()) {
        if (i)
          cout << 0;
        else
          cout << 1;
      } else {
        cout << digitos[i];
      }
    }
  cout << endl;
  return 0;
}
