#include <bits/stdc++.h>
using namespace std;
int main() {
  long long nn, mm;
  cin >> nn >> mm;
  vector<long long> aa(nn + 1, -1);
  long long ss, cc;
  for (long long ii = 0; ii < mm; ii++) {
    cin >> ss >> cc;
    if (aa[ss] == -1 || aa[ss] == cc) {
      aa[ss] = cc;
    } else {
      puts("-1");
      return 0;
    }
  }
  if (aa[1] == 0 && nn != 1) {
    puts("-1");
    return 0;
  } else if (aa[1] == -1) {
    aa[1] = 1;
  }
  for (long long ii = 2; ii <= nn; ii++) {
    if (aa[ii] == -1) {
      aa[ii] = 0;
    }
  }
  for (long long ii = 1; ii <= nn; ii++) {
    cout << aa[ii];
  }
  cout << endl;
  return 0;
}
