#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
constexpr long long INF = LLONG_MAX / 10;
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
using namespace std;
inline long long gcd(long long a, long long b) {
  while (b) {
    long long c = a;
    a = b;
    b = c % b;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool isprime(long long n) {
  if (n == 1) return false;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long mypow(long long a, long long b) {
  if (!b) return 1;
  if (b & 1) return mypow(a, b - 1) * a;
  long long memo = mypow(a, b >> 1);
  return memo * memo;
}
long long modpow(long long a, long long b,
                 long long m = (long long)1000000007) {
  if (!b) return 1;
  if (b & 1) return modpow(a, b - 1, m) * a % m;
  long long memo = modpow(a, b >> 1, m);
  return memo * memo % m;
}
long long n, m, s, c;
signed main() {
  cin >> n >> m;
  string ans(n, '.');
  for (long long i = 0; i < (m); i++) {
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[s - 1] == '.')
      ans[s - 1] = '0' + c;
    else if (ans[s - 1] - '0' != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (long long i = 0; i < (n); i++) {
    if (ans[i] == '.') {
      if (i)
        ans[i] = '0';
      else
        ans[i] = '1';
    }
  }
  cout << ans << endl;
  return 0;
}
