#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vvll = vector<vll>;
using vstr = vector<string>;
static inline void ignore_ret(int x) { x++; }
template <class T>
inline int sgn(T x) {
  return (x > 0) - (x < 0);
}
template <class T>
inline ll factorial(T n) {
  if (n == 0) return 1;
  ll r = 1;
  for (T i = 2; i <= n; i++) r *= i;
  return r;
}
template <class T>
inline map<T, T> factorize(T n) {
  map<T, T> r;
  for (T i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      r[i]++;
      n /= i;
    }
  }
  if (n != 1) r[n] = 1;
  return r;
}
template <class T>
inline bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline T nPr(T n, T k) {
  if (n < k || n < 0 || k < 0) return 0;
  T r = 1;
  for (T i = n - k + 1; i <= n; i++) r *= i;
  return r;
}
template <class T>
inline T nCr(T n, T k) {
  if (n < k || n < 0 || k < 0) return 0;
  T r = 1;
  k = min(k, n - k);
  for (T i = n - k + 1; i <= n; i++) r *= i;
  return r / factorial(k);
}
template <class T>
inline void print(T v) {
  cout << "[ ";
  for (auto x : v) cout << x << ' ';
  cout << "]\n";
}
template <class T>
inline void print_d(T v) {
  for (auto x : v) cout << x;
  cout << '\n';
}
template <class T>
inline T min(vector<T> v) {
  return *min_element((v).begin(), (v).end());
}
template <class T>
inline T max(vector<T> v) {
  return *max_element((v).begin(), (v).end());
}
template <class T>
inline ll sum(T v) {
  return reduce((v).begin(), (v).end(), 0LL);
}
template <class T>
inline T gcd(vector<T> v) {
  T r = v[0];
  for (T i = 1; i < v.size(); i++) r = gcd(r, v[i]);
  return r;
}
template <class T>
inline T lcm(vector<T> v) {
  T r = v[0];
  for (T i = 1; i < v.size(); i++) r = lcm(r, v[i]);
  return r;
}
template <class T>
inline double abs(T v) {
  return sqrt(reduce((v).begin(), (v).end(), 0.0,
                     [](int s, int v) { return s += v * v; }));
}
template <class T>
inline T vector_add(T u, T v) {
  ll s = u.size();
  if (s > v.size()) return {};
  T r;
  for (ll i = 0, i_len = (s); i < i_len; i++) r.emplace_back(u[i] + v[i]);
  return r;
}
template <class T>
inline T vector_subtract(T u, T v) {
  ll s = u.size();
  if (s > v.size()) return {};
  T r;
  for (ll i = 0, i_len = (s); i < i_len; i++) r.emplace_back(u[i] - v[i]);
  return r;
}
template <class T>
inline T dot_product(vector<T> u, vector<T> v) {
  if (u.size() < v.size()) return 0;
  T r = 0;
  for (T i = 0; i < u.size(); i++) r += u[i] * v[i];
  return r;
}
template <class T>
inline T cross_product(T u, T v) {
  T r(3);
  r[0] = u[1] * v[2] - u[2] * v[1];
  r[1] = u[2] * v[0] - u[0] * v[2];
  r[2] = u[0] * v[1] - u[1] * v[0];
  return r;
}
template <class T>
inline T min(set<T> v) {
  return *min_element((v).begin(), (v).end());
}
template <class T>
inline T max(set<T> v) {
  return *max_element((v).begin(), (v).end());
}
template <class T>
inline T gcd(set<T> v) {
  T r = 0;
  for (T x : v) r = (r == 0) ? x : gcd(r, x);
  return r;
}
template <class T>
inline T lcm(set<T> v) {
  T r = 0;
  for (T x : v) r = (r == 0) ? x : lcm(r, x);
  return r;
}
void solve(ll N, ll M, vector<ll> s, vector<ll> c) {
  string ans(N, 'x');
  for (ll i = 0, i_len = (M); i < i_len; i++) {
    if (ans[s[i] - 1] == 'x') {
      ans[s[i] - 1] = c[i] + '0';
    } else if (ans[s[i] - 1] != c[i] + '0') {
      cout << "-1\n";
      return;
    }
  }
  for (ll i = 0, i_len = (N); i < i_len; i++) {
    if (ans[i] == 'x') {
      ans[i] = (i == 0) ? '1' : '0';
    }
  }
  cout << ((ans[0] == '0') ? "-1" : ans) << endl;
}
int main() {
  ll N;
  ignore_ret(scanf("%lld", &N));
  ll M;
  ignore_ret(scanf("%lld", &M));
  vector<ll> s(M);
  vector<ll> c(M);
  for (int i = 0; i < M; i++) {
    ignore_ret(scanf("%lld", &s[i]));
    ignore_ret(scanf("%lld", &c[i]));
  }
  solve(N, M, move(s), move(c));
  return 0;
}
