#include <bits/stdc++.h>
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
long long gcd(long long a, long long b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long pow(long long x, long long n) {
  x %= 998244353;
  if (n == 0) return 1;
  if (n % 2 == 0)
    return (pow((x * x) % 998244353, n / 2) % 998244353);
  else
    return (x * pow(x, n - 1)) % 998244353;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<char> b(m);
  for (long long i = 0; i < m; i++) cin >> a[i] >> b[i], a[i]--;
  string s = "";
  for (long long i = 0; i < n; i++) s += ' ';
  int count = 0;
  for (long long i = 0; i < m; i++) {
    if (s[a[i]] == ' ' || s[a[i]] == b[i])
      s[a[i]] = b[i];
    else
      count++;
  }
  if (count >= 1)
    cout << -1 << endl;
  else if (n == 0)
    cout << s << endl;
  else if (s[0] == '0' && n != 1)
    cout << -1 << endl;
  else {
    if (s[0] == ' ') s[0] = '1';
    for (long long i = 0; i < n; i++) {
      if (s[i] == ' ') s[i] = '0';
    }
    cout << s << endl;
  }
}
