#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = MOD * MOD;
const long double EPS = 1e-9;
long long gcd(long long m, long long n) {
  long long a = max(m, n);
  long long b = min(m, n);
  while (b != 1 && b != 0) {
    a %= b;
    swap(a, b);
  }
  return b == 1 ? 1 : a;
}
long long lcm(long long m, long long n) { return m / gcd(m, n) * n; }
long long power_mod(long long a, long long power, long long mod) {
  long long value = 1;
  while (power != 0) {
    if (power & 1) value = (value * a) % mod;
    a = (a * a) % mod;
    power = power >> 1;
  }
  return value % mod;
}
long long modinv(long long a, long long mod) {
  return power_mod(a, mod - 2, mod);
}
long long power_normal(long long a, long long power) {
  long long value = 1;
  while (power != 0) {
    if (power & 1) value = value * a;
    a = a * a;
    power = power >> 1;
  }
  return value;
}
long long combination(long long n, long long r) {
  long long numerator = 1;
  long long denomenator = 1;
  for (long long i = 0; i < r; i++) {
    (numerator *= long long(n - i)) %= MOD;
    (denomenator *= modinv(i + 1, MOD)) %= MOD;
  }
  return (numerator * denomenator) % MOD;
}
long long bin_search(long long key, long long A[], long long left,
                     long long right) {
  while (right >= left) {
    long long mid = left + (right - left) / 2;
    if (A[mid] == key)
      return mid;
    else if (A[mid] > key)
      right = mid - 1;
    else if (A[mid] < key)
      left = mid + 1;
  }
  return -1;
}
long long fact(long long n) {
  if (n == 0) return 1;
  return n * fact(n - 1);
}
bool is_prime(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 bool_sum(long long a1, long long a2) {
  if (a1 == 1 || a2 == 1) return 1;
  return 0;
}
std::map<long long, long long> prime_decomposition(long long n) {
  long long i = 2;
  std::map<long long, long long> table;
  while (i * i <= n) {
    while (n % i == 0) {
      table[i]++;
      n /= i;
    }
    i++;
  }
  if (n > 1) table[n] = 1;
  return table;
}
const long long MAX_N = 200005;
long long n, m, s[10], c[10];
bool okay = true;
long long answer = 0;
int main(void) {
  cin >> (n) >> (m);
  for (long long((i)) = 0; ((i)) < ((m)); ((i))++) cin >> (s[(i)]) >> (c[(i)]);
  std::vector<std::pair<long long, long long> > hoge;
  for (long long(i) = 0; (i) < (m); (i)++)
    hoge.push_back(make_pair(s[i], c[i]));
  sort((hoge).begin(), (hoge).end());
  for (long long(i) = 0; (i) < (m); (i)++)
    if (hoge[i].first == 1 && hoge[i].second == 0) okay = false;
  for (long long(i) = 0; (i) < (m); (i)++)
    for (long long(j) = (i + 1); (j) < (m); (j)++)
      if (hoge[i].first == hoge[j].first && hoge[i].second != hoge[j].second)
        okay = false;
  long long each_dig[n + 5];
  if (okay && n > 1) {
    each_dig[0] = 1;
    for (long long(i) = (1); (i) < (n); (i)++) each_dig[i] = 0;
    for (long long(i) = 0; (i) < (m); (i)++)
      each_dig[hoge[i].first - 1] = hoge[i].second;
    for (long long(i) = 0; (i) < (n); (i)++) cout << (each_dig[i]);
    cout << ("") << endl;
  } else if (okay && n == 1) {
    each_dig[0] = 0;
    for (long long(i) = (1); (i) < (n); (i)++) each_dig[i] = 0;
    for (long long(i) = 0; (i) < (m); (i)++)
      each_dig[hoge[i].first - 1] = hoge[i].second;
    for (long long(i) = 0; (i) < (n); (i)++) cout << (each_dig[i]);
    cout << ("") << endl;
  } else
    cout << (-1) << endl;
  return 0;
}
