#include <bits/stdc++.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  auto s = new int[M];
  auto c = new char[M];
  for (int i = 0; i < M; i++) scanf("%d %c", s + i, c + i);
  char* res = new char[N + 1]{};
  char m1[] = "-1";
  if (N == 1) {
    if (M == 0)
      res[0] = '0';
    else {
      for (int i = 0; i < M; i++) {
        if (res[0] != 0 && res[0] != c[i]) {
          res = m1;
          break;
        } else {
          res[0] = c[i];
        }
      }
    }
  }
  for (int i = 0; i < M; i++) {
    if ((res[s[i] - 1] != 0 && res[s[i] - 1] != c[i]) ||
        (s[i] == 1 && c[i] == '0')) {
      res = m1;
      break;
    } else {
      res[s[i] - 1] = c[i];
    }
  }
  if (res != m1)
    for (int i = 0; i < N; i++)
      if (res[i] == 0) res[i] = i == 0 ? '1' : '0';
  printf(res);
  return 0;
}
