#include <bits/stdc++.h>
using namespace std;
long long int N = 100000, M = 100000;
long long int MOD = 1000000007;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int pow1(long long int n, long long int k, long long int mm) {
  if (k == 0) return 1;
  if (k % 2 == 0) return (pow1((n % mm) * (n % mm), k / 2, mm)) % mm;
  return ((n % mm) * (pow1((n % mm) * (n % mm), k / 2, mm) % mm)) % mm;
}
long long int pow(long long int a, long long int b, long long int m) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % m;
    b = b / 2;
    a = (a * a) % m;
  }
  return ans;
}
long long int modinv(long long int k) { return pow(k, MOD - 2, MOD); }
long long int ncr(long long int n, long long int c) {
  long long int t = 1;
  c = min(c, n - c);
  for (long long int i = 1; i <= c; i++) {
    t = (t * (n - i + 1)) % MOD;
    t = (t * modinv(i)) % MOD;
  }
  return t;
}
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int a[m + 1], b[m + 1];
  for (long long int i = 0; i < m; i++) cin >> a[i] >> b[i];
  long long int c[n + 1];
  for (long long int i = 0; i < n; i++) c[i] = -1;
  for (long long int i = 0; i < m; i++) c[a[i] - 1] = b[i];
  for (long long int i = 0; i < m; i++) {
    if (c[i] == -1) c[i] = 0;
  }
  if (c[0] == 0)
    cout << "-1";
  else {
    for (long long int i = 0; i < n; i++) cout << c[i];
  }
}
