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