#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int pow_int(int a, int n) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
int s[10], c[10];
int N, M;
string int_to_string(int X) {
  string res;
  while (X > 0) {
    res += '0' + (X % 10);
    X /= 10;
  }
  reverse(res.begin(), res.end());
  return res;
}
bool check(int X) {
  string sX = int_to_string(X);
  for (int i = 0; i < M; ++i) {
    if (sX[s[i] - 1] - '0' != c[i]) return false;
  }
  return true;
}
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &s[i], &c[i]);
  }
  for (int i = pow_int(10, N - 1); i < pow_int(10, N); ++i) {
    if (check(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
