#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long long MAX_N = 200100;
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long>> vpii;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    vpii.emplace_back(a, b);
  }
  long long t = 1;
  for (long long i = 0; i < n; i++) {
    t *= 10;
  }
  bool flg = true;
  for (long long i = 0; i < t; i++) {
    flg = true;
    string s = to_string(i);
    for (long long j = 0; j < vpii.size(); j++) {
      long long a = vpii[j].first;
      long long b = vpii[j].second;
      if (s.size() < a) {
        flg = false;
        break;
      }
      if (s[a - 1] - '0' != b) {
        flg = false;
        break;
      }
    }
    if (flg) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
