#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
const double PI = acos(-1.0);
const long double EPS = 1e-10;
const int64_t INF = 1e18 + 10;
template <typename t>
t lcm(t a, t b) {
  return (a * b) / __gcd(a, b);
}
template <typename t>
t gcd(t a, t b) {
  return __gcd(a, b);
}
template <typename t>
t mul_mod(t a, t b, t m) {
  t res = ((a % m) * (b % m) % m);
  return res;
}
template <typename t>
t add_mod(t a, t b, t m) {
  t res = ((a % m) + (b % m)) % m;
  return res;
}
template <typename t>
t pow_mod(t a, t b, t m) {
  t res = 1;
  while (b) {
    if (b & 1) res = mul_mod(res, a, m);
    a = mul_mod(a, a, m), b >>= 1;
  }
  return res % m;
}
template <typename t>
vector<t> num_vec(t num) {
  t res;
  while (num) res.push_back(num % 10), num /= 10;
  return res;
}
template <typename t>
t vec_num(t vec) {
  t res = 0;
  long long mul = 1;
  for (long long i = 0; i < (int)vec.size(); i++) res = vec[i] * mul, mul *= 10;
  return res;
}
int32_t main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  auto tstart = clock();
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > d(m);
  for (long long i = 0; i < m; i++) cin >> d[i].first >> d[i].second;
  vector<int> di(n, -1);
  for (long long i = 0; i < m; i++) {
    if (di[d[i].first - 1] == -1)
      di[d[i].first - 1] = d[i].second;
    else if (di[d[i].first - 1] != d[i].second)
      return cout << -1 << endl, 0;
  }
  int pos = -1;
  for (long long i = 0; i < n; i++)
    if (di[i] != -1) {
      pos = i;
      break;
    }
  for (long long i = 0; i < pos + 1; i++) di[i] = 1;
  for (long long i = pos + 1; i < n; i++)
    if (di[i] == -1) di[i] = 0;
  if (di[0] == 0 && (int)di.size() > 0) return cout << -1 << endl, 0;
  for (auto i : di) cout << i;
  cerr << setprecision(2) << fixed
       << "Time elapsed: " << (double)(clock() - tstart) / CLOCKS_PER_SEC
       << endl;
  return 0;
}
