#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
template <typename T>
void input_vec(vector<T> &a, ll n) {
  assert(a.empty());
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  assert(a.empty());
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }
ll modinv(ll n, ll mod) {
  assert(mod > 0 && my::gcd(n, mod) == 1);
  n %= mod;
  if (n < 0) n += mod;
  ll a = mod, b = n, x = 1, y = 0;
  while (b != 0) {
    ll q = a / b, r = a % b;
    a = b;
    b = r;
    y -= q * x;
    swap(x, y);
  }
  y %= mod;
  if (y < 0) y += mod;
  return y;
}
bool is_prime(ll n) {
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
class unionfind {
 private:
  ll n_;
  vector<ll> par;
  ll root(ll a) {
    if (par.at(a) < 0)
      return a;
    else {
      par.at(a) = root(par.at(a));
      return par.at(a);
    }
  }

 public:
  unionfind(ll n) : n_(n), par(n, -1) {}
  void unite(ll a, ll b) {
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    if (root(a) == root(b))
      return;
    else {
      ll ra = root(a), rb = root(b);
      if (-par.at(ra) < -par.at(rb)) swap(ra, rb);
      par.at(ra) += par.at(rb);
      par.at(rb) = ra;
    }
  }
  bool is_same(ll a, ll b) {
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    return root(a) == root(b);
  }
  ll size(ll a) {
    assert(0 <= a && a < n_);
    return -par.at(root(a));
  }
};
}  // namespace my
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s, c;
  for (int i = 0; i < m; i++) {
    int h, g;
    cin >> h >> g;
    s.push_back(h);
    c.push_back(g);
  }
  int ans = -1;
  for (int num = (int)pow(10, n - 1); num < (int)pow(10, n); num++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      if ((num / (int)pow(10, n - s.at(i))) % 10 != c.at(i)) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans = num;
      break;
    }
  }
  cout << ans << endl;
}
