#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1 << 30) - 1;
template <class T = int>
inline T in() {
  T x;
  cin >> x;
  return (x);
}
template <typename T>
inline ll suma(const vector<T>& a) {
  ll res(0);
  for (auto&& x : a) res += x;
  return res;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
ll mod_pow(ll x, ll n, ll mod = INF) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vi s(m), c(m);
  for (int i = (0); i < (m); ++i) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (int i = mod_pow(10, n - 1); i < mod_pow(10, n); ++i) {
    string k = to_string(i);
    bool ok = true;
    for (int j = (0); j < (m); ++j) {
      if (k[s[j]] != c[j] + '0') ok = false;
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
