#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> keta;
  for (int i = 0; i < m; i++) {
    int s;
    cin >> s;
    s--;
    int c;
    cin >> c;
    keta.push_back(make_pair(s, c));
  }
  auto isOK = [&](int num) {
    string s = to_string(num);
    for (int i = 0; i < m; i++) {
      if (s.at(keta[i].first) != (char)(keta[i].second + '0')) {
        return false;
      }
    }
    return true;
  };
  int start = 1;
  int end = 10;
  for (int i = 0; i < n - 1; i++) {
    start *= 10;
    end *= 10;
  }
  for (int num = start; num < end; num++) {
    if (isOK(num)) {
      cout << num << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
