#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using IR = pair<int, int>;
int N, M;
int main() {
  scanf("%d%d", &N, &M);
  if (M == 0) {
    if (N == 1) {
      printf("%d", 0);
      return 0;
    } else if (N == 2) {
      printf("%d", 10);
      return 0;
    } else if (N == 3) {
      printf("%d", 100);
      return 0;
    }
  }
  vector<bool> dec(N);
  vector<int> integer;
  for (int i = 0; i < N; i++) integer.push_back(0);
  if (N >= 2) {
    integer[0] = 1;
  }
  for (int i = 0; i < M; i++) {
    int s, c;
    scanf("%d%d", &s, &c);
    if (N >= 2 && s == 1 && c == 0) {
      printf("%d", -1);
      return 0;
    }
    if (dec[s - 1]) {
      printf("%d", -1);
      return 0;
    }
    dec[s - 1] = true;
    integer[s - 1] = c;
  }
  for (int i = 0; i < N; i++) {
    printf("%d", integer[i]);
  }
}
