#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001000;
const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > in(M);
  for (int i = 0; i < M; ++i) {
    cin >> in[i].first >> in[i].second;
  }
  int start = 1 * pow(10, N - 1);
  int end = 9 * ((N == 1) ? 1 : ((N == 2) ? 11 : 111));
  int ans = -1;
  for (; start <= end; ++start) {
    bool ok = true;
    for (int i = 0; i < M; ++i) {
      int digit = start / (int)pow(10, N - in[i].first) % 10;
      if (digit != in[i].second) ok = false;
    }
    if (ok) {
      ans = start;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
