#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[5], c[5];
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  int x[5];
  fill(x, x + 5, -1);
  for (int i = 0; i < M; i++) {
    if (x[s[i]] == -1 || x[s[i]] == c[i]) {
      x[s[i]] = c[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (x[0] == 0) {
    cout << -1 << endl;
    return 0;
  } else {
    for (int i = 0; i < N; i++) {
      if (i == 0 && x[i] == -1) {
        cout << 1;
      } else if (x[i] == -1) {
        cout << 0;
      } else {
        cout << x[i];
      }
    }
    cout << endl;
  }
  return 0;
}
