#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(n, 10);
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    l[s - 1] = min(l[s - 1], c);
  }
  for (int i = 0; i < (int)(n); i++) {
    if (l[0] == 10) {
      l[0] = 1;
      continue;
    }
    if (l[i] == 10) {
      l[i] = 0;
    }
  }
  if (l[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < (int)(n); i++) {
    cout << l[i];
  }
  cout << endl;
}
