#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int m;
  int s;
  int c;
  bool check[4];
  short ans[4];
  for (int i = 1; i <= 3; i++) ans[i] = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    ans[s] = c;
    check[s] = true;
  }
  if ((n == 3 && ans[1] == 0)) {
    if (check[2] == true && check[3] == true) {
      ans[1] = 1;
      for (int i = 1; i <= n; i++) {
        printf("%d", ans[i]);
      }
      cout << endl;
    } else
      cout << -1 << endl;
  } else {
    if (n == 2 && ans[1] == 0) ans[1] = 1;
    for (int i = 1; i <= n; i++) {
      printf("%d", ans[i]);
    }
    cout << endl;
  }
}
