#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
template <typename T>
bool chmax(T &a, const T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
ll pow2(const T n) {
  return (1LL << n);
}
template <typename T>
void cosp(const T n) {
  cout << n << ' ';
}
template <typename T>
void co(const T n) {
  cout << n << '\n';
}
template <typename T1, typename T2>
void co(pair<T1, T2> p) {
  cout << p.first << ' ' << p.second << '\n';
}
template <typename T>
void co(const Vec1<T> &v) {
  for (T i : v) cosp(i);
  cout << '\n';
}
template <typename T>
void co(initializer_list<T> v) {
  for (T i : v) cosp(i);
  cout << '\n';
}
template <typename T>
void ce(const T n) {
  cerr << n << endl;
}
void sonic() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void setp(const ll n) { cout << fixed << setprecision(n); }
const ll INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;
const ld PI = acos(-1);
const ld EPS = 1e-11;
int main(void) {
  ll n;
  cin >> n;
  string t;
  for (ll(i) = (0); (i) < (n); ++(i)) t += '-';
  ll m;
  cin >> m;
  for (ll(i) = (0); (i) < (m); ++(i)) {
    ll s;
    char c;
    cin >> s >> c;
    s--;
    if (t[s] == '-')
      t[s] = c;
    else if (t[s] != c) {
      co(-1);
      return 0;
    }
  }
  if (t[0] == '0') {
    co(-1);
    return 0;
  }
  for (ll(i) = (0); (i) < (n); ++(i)) {
    if (t[i] == '-') {
      if (!i)
        t[i] = '1';
      else
        t[i] = '0';
    }
  }
  co(t);
  return 0;
}
