#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, x[5];
  cin >> a >> b;
  for (int i = 1; i <= a; i++) {
    x[i] = -1;
  }
  while (b--) {
    cin >> c >> d;
    if (x[c] == -1)
      x[c] = d;
    else if (x[c] != d) {
      cout << "-1" << endl;
      return 0;
    }
  }
  if (x[1] == 0) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 1; i <= a; i++) {
    if (x[i] == -1) x[i] = 0;
  }
  if (x[1] == 0 && a != 1) x[1] = 1;
  for (int i = 1; i <= a; i++) {
    cout << x[i];
  }
  cout << endl;
  return 0;
}
