#include <bits/stdc++.h>
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); }
int ketasuu(long long h) {
  if (h < 0)
    return (-(ketasuu(-h)));
  else if (h < 10)
    return (1);
  else
    return (1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    inv[i] = 1000000007 - inv[1000000007 % i] * (1000000007 / i) % 1000000007;
    finv[i] = finv[i - 1] * inv[i] % 1000000007;
  }
}
vector<long long> soinnsuubunnkai(long long n) {
  vector<long long> a;
  while (n % 2 == 0) {
    a.push_back(2);
    n /= 2;
  }
  long long f = 3;
  while (f * f <= n) {
    if (n % f == 0) {
      a.push_back(f);
      n /= f;
    } else
      f += 2;
  }
  if (n != 1) a.push_back(n);
  return (a);
}
long long com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % 1000000007) % 1000000007;
}
long long pow(long long a, long long b) {
  a = a % 1000000007;
  if (b == 0)
    return (1);
  else if (b % 2 == 0)
    return (pow((a * a) % 1000000007, b / 2));
  else
    return (a * (pow(a, b - 1)));
}
void solve() {}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<char> b(m);
  for (int i = 0; i < m; i++) cin >> a[i] >> b[i], a[i]--;
  string s = "";
  for (int i = 0; i < n; i++) s += ' ';
  int count = 0;
  for (int 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 (s[0] == '0')
    cout << -1 << endl;
  else {
    if (s[0] == ' ') s[0] = '1';
    for (int i = 0; i < n; i++) {
      if (s[i] == ' ') s[i] = '0';
    }
    cout << s << endl;
  }
}
