#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  bool ok = true;
  for (int i = 0; i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    if (a.at(s - 1) == -1) {
      a.at(s - 1) = c;
    } else
      ok = a.at(s - 1) == c;
  }
  if (n != 1 && a.at(0) == 0) ok = false;
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < (n); ++i) {
    if (a.at(i) == -1) {
      a.at(i) = i == 0 ? 1 : 0;
    }
    cout << a.at(i);
  }
  cout << endl;
  return 0;
}
