#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const int INF = 0x3F3F3F3F;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 9;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > arr(m);
  for (int i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    arr[i] = make_pair(a, b);
  }
  for (int i = (pow(10, n - 1) + EPS); i < int(pow(10, n) + EPS); i++) {
    bool can = true;
    for (auto a : arr) {
      can &= ((i / int(pow(10, n - a.first) + EPS)) % 10 == a.second);
    }
    if (can) return cout << i, 0;
  }
  cout << -1;
  return 0;
}
