#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long ppow(long long a, long long b, long long mod) {
  a %= mod;
  long long ans = 1 % mod;
  while (b) {
    if (b & 1) ans = (long long)ans * a % mod;
    a = (long long)a * a % mod;
    b >>= 1;
  }
  return ans;
}
long long readdd() {
  long long x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return f * x;
}
void printtt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) printtt(x / 10);
  putchar(x % 10 + '0');
}
bool addd(long long a, long long b) { return a > b; };
const long long maxm = 1e5 + 5;
long long a[maxm];
signed main() {
  memset(a, -1, sizeof a);
  long long n = readdd(), m = readdd();
  for (signed long long(mm) = 1; (mm) <= (m); (mm)++) {
    long long x = readdd(), xx = readdd();
    if (a[x] != -1 && a[x] != xx) {
      puts("-1");
      return 0;
    }
    a[x] = xx;
  }
  if (a[1] == -1) a[1] = 1;
  for (signed long long(i) = 1; (i) <= (n); (i)++) {
    if (a[i] == -1) a[i] = 0;
  }
  for (signed long long(i) = 1; (i) <= (n); (i)++) printtt(a[i]);
  return 0;
}
