#include <bits/stdc++.h>
using namespace std;
int power10(int n) {
  int ret = 1;
  for (int i = 0; i < n; i++) ret *= 10;
  return ret;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int s[10], c[10];
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  int num = -1;
  for (int i = power10(N - 1); i <= power10(N) - 1; i++) {
    string S = to_string(i);
    bool ok = true;
    for (int j = 0; j < M; j++) {
      if (S[s[j]] - '0' != c[j]) ok = false;
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
