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