#include <bits/stdc++.h>
using namespace std;
int k, a[40];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    if (a[x] != y && a[x] || n > 2 && x == 1 && y == 0) {
      cout << -1;
      return 0;
    }
    a[x] = y;
  }
  int i = 1;
  if (a[1] == 0 && n > 2) cout << 1, i++;
  for (; i <= n; i++) cout << a[i];
}
