#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> b(3, -1);
  bool flg = true;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && n != 1 && c == 0) {
      flg = false;
    }
    if (b[s - 1] == -1) {
      b[s - 1] = c;
    } else if (b[s - 1] != c) {
      flg = false;
    }
  }
  for (int i = 0; i < n; i++) {
    if (b[i] == -1) b[i] = 0;
  }
  if (b[0] == 0) b[0] = 1;
  if (flg) {
    for (int i = 0; i < n; i++) {
      cout << b[i];
    }
    cout << endl;
  } else {
    puts("-1");
  }
}
