#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
using namespace std;
using ll = long long;
using ld = long double;
const long long mod = 1e9 + 7;
const long long Mod = 998244353;
const ll inf = 3 * 1e18;
const long long Inf = 15 * 1e8;
const vector<long long> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1};
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
ll read() {
  ll u, k = scanf("%lld", &u);
  return u;
}
string reads() {
  string s;
  cin >> s;
  return s;
}
pair<long long, long long> readh(bool g = 0) {
  pair<long long, long long> u;
  ll k = scanf("%lld %lld", &u.first, &u.second);
  if (g) u.first--, u.second--;
  return u;
}
void printh(pair<long long, long long> t) {
  printf("%lld %lld\n", t.first, t.second);
}
bool inarea(pair<long long, long long> t, long long h, long long w) {
  return 0 <= t.first && t.first < h && 0 <= t.second && t.second < w;
}
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % p;
    x = x * x % p;
    n >>= 1;
  }
  return res;
}
ll bitcount(ll x) {
  long long sum = 0;
  for (long long i = 0; i < 60; i++)
    if ((1ll << i) & x) sum++;
  return sum;
}
signed main() {
  long long n = read();
  long long m = read();
  vector<pair<long long, long long> > a;
  for (long long(i) = 0; (i) < (m); (i)++) a.emplace_back(readh());
  for (long long i = pow(10, n - 1); i < pow(10, n); i++) {
    string s = to_string(i);
    bool l = 1;
    for (long long(j) = 0; (j) < (m); (j)++) {
      if (s[a[j].first - 1] != (char)(a[j].second + '0')) {
        l = 0;
      }
    }
    if (l) {
      cout << i << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
}
