#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > a(m);
  for (size_t i = 0; i < m; i++) {
    cin >> a.at(i).first >> a.at(i).second;
  }
  sort(a.begin(), a.end());
  vector<int> num(n, 0);
  num.at(0) = 1;
  if (m == 0) {
    for (size_t i = 0; i < n; i++) {
      cout << num.at(i);
    }
    cout << endl;
    return 0;
  }
  if (a.at(0).first == 1 && a.at(0).second == 0 && n != 1) {
    cout << -1 << endl;
    return 0;
  } else {
    num.at(a.at(0).first - 1) = a.at(0).second;
  }
  for (size_t i = 1; i < m; i++) {
    if (a.at(i).first == a.at(i - 1).first) {
      if (a.at(i).second != a.at(i - 1).second) {
        cout << -1 << endl;
        return 0;
      } else {
        num.at(a.at(i).first - 1) = a.at(i).second;
      }
    } else {
      num.at(a.at(i).first - 1) = a.at(i).second;
    }
  }
  for (size_t i = 0; i < n; i++) {
    cout << num.at(i);
  }
  cout << endl;
}
