#include <bits/stdc++.h>
using namespace std;
long long N, K, T, W, H, M, C;
const int MAX = 510000;
const int MOD = 1e9;
const double PI = 3.14159265358979323846;
int length(vector<int> v, int u, int HW) {
  if (v.size() == 0) return HW;
  if (v[0] > u) return v[0];
  if (v[v.size() - 1] < u)
    return HW - v[v.size() - 1] - 1;
  else {
    int i = lower_bound(v.begin(), v.end(), u) - v.begin();
    return v[i] - v[i - 1] - 1;
  }
}
int main() {
  cin >> N >> M;
  vector<pair<int, int>> v;
  for (int i = 0; i < (int)(M); i++) {
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  int init = pow(10, N - 1);
  int fin = pow(10, N) - 1;
  vector<int> digit(N);
  for (int n = init; n <= fin; ++n) {
    int m = n;
    bool flag = true;
    for (int i = 0; i < (int)(N); i++) {
      digit[i] = m % 10;
      m /= 10;
    }
    for (auto u : v) {
      if (digit[N - u.first] != u.second) flag = false;
    }
    if (flag) {
      cout << n;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
