#include <bits/stdc++.h>
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int, int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;
int main() {
  int n, m;
  cin >> n >> m;
  vint s(m), c(m);
  for (int i = 0; i < (int)(m); i++) cin >> s[i] >> c[i];
  for (int i = (int)pow(10, n - 1); i <= (int)pow(10, n) - 1; i++) {
    vint x;
    int tmp = i;
    for (int j = 0; j < (int)(n); j++) {
      x.push_back(tmp % 10);
      tmp /= 10;
    }
    bool ok = true;
    for (int j = 0; j < (int)(m); j++) {
      if (x[n - s[j]] != c[j]) ok = false;
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
