#include <bits/stdc++.h>
using namespace std;
long long gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return (x * y) / gcd(x, y); }
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > sc(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> sc[i].first >> sc[i].second;
  }
  int min_n = 1;
  for (int i = 0; i < (int)(n - 1); i++) {
    min_n *= 10;
  }
  int max_n = min_n * 10;
  int ans = -1;
  bool isbad = false;
  for (min_n; min_n < max_n; min_n++) {
    isbad = false;
    for (int i = 0; i < (int)(m); i++) {
      int keta = n - sc[i].first + 1;
      if (keta == 1) {
        if (min_n % 10 != sc[i].second) isbad = true;
      } else if (keta == 2) {
        if ((min_n % 100) / 10 != sc[i].second) isbad = true;
      } else {
        if (min_n / 100 != sc[i].second) isbad = true;
      }
    }
    if (!isbad) {
      ans = min_n;
      break;
    }
  }
  cout << ans << endl;
}
