#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
void Main() {
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  vector<int> keta(n, -1);
  for (long long i = (0); i < (m); i++) {
    int s, c;
    cin >> s >> c;
    if (keta[s - 1] > -1 && keta[s - 1] != c) {
      cout << -1 << endl;
      return;
    }
    keta[s - 1] = c;
  }
  if (keta[0] == 0 && n > 1) {
    cout << -1 << endl;
    return;
  }
  if (keta[0] == -1) keta[0] = 1;
  for (long long i = (1); i < (n); i++) {
    if (keta[i] == -1) keta[i] = 0;
  }
  for (long long i = (0); i < (n); i++) cout << keta[i];
  cout << endl;
}
int main() {
  Main();
  return 0;
}
