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