#include <bits/stdc++.h>
using namespace std;
long long prck(long long n) {
  long long f = 1;
  if (n == 1)
    f = 0;
  else if (n == 2)
    f = 1;
  else if (n % 2 == 0)
    f = 0;
  else {
    long long i;
    for (i = 3; (i * i <= n) && (f == 1); i += 2) {
      if (n % i == 0) f = 0;
    }
  }
  return f;
}
long long nCr(long long n, long long r) {
  long long i, res = 1;
  if (r > n - r) r = n - r;
  for (i = 0; i < r; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long btod(string n) {
  long long lg = n.length();
  long long i, val = 0, bs = 1;
  for (i = lg - 1; i >= 0; i--) {
    if (n[i] == '1') {
      val += bs;
    }
    bs *= 2;
  }
  return val;
}
long long ston(string s) {
  long long val = 0, bs = 1;
  long long sl = s.length();
  sl--;
  while (sl >= 0) {
    val += ((s[sl] - 48) * bs);
    bs *= 10;
    sl--;
  }
  return val;
}
long long nCrModpDP(long long n, long long r, long long p) {
  long long i, j, C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = min(i, r); j > 0; j--) {
      C[j] = (C[j] + C[j - 1]) % p;
    }
  }
  return C[r];
}
long long nCrModpLucas(long long n, long long r, long long p) {
  if (r == 0) return 1;
  long long ni = n % p, ri = r % p;
  return (nCrModpLucas(n / p, r / p, p) * nCrModpDP(ni, ri, p)) % p;
}
long long pwr(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modInverse(long long n, long long p) { return pwr(n, p - 2, p); }
long long nCrModPFermat(long long n, long long r, long long p,
                        long long fac[]) {
  if (r == 0) return 1;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
int calcDate(int date, int month, int year) {
  if (month == 1) {
    month = 13;
    year--;
  }
  if (month == 2) {
    month = 14;
    year--;
  }
  int q = date, m = month, k = year % 100, j = year / 100;
  int day = q + (13 * (m + 1)) / 5 + k + (k / 4) + (j / 4) + 5 * j;
  day = day % 7;
  return day;
}
vector<vector<long long>> matmul(vector<vector<long long>> a,
                                 vector<vector<long long>> b) {
  long long k = a.size();
  vector<vector<long long>> c(k, vector<long long>(k));
  long long i, j, l;
  for (i = 0; i < k; i++) {
    for (j = 0; j < k; j++) {
      for (l = 0; l < k; l++) {
        c[i][j] = (c[i][j] + a[i][l] * b[l][j]) % 1000000007;
      }
    }
  }
  return c;
}
vector<vector<long long>> matexp(vector<vector<long long>> a, long long p) {
  if (p == 1) return a;
  if (p & 1) return matmul(a, matexp(a, p - 1));
  vector<vector<long long>> x = matexp(a, p / 2);
  return matmul(x, x);
}
long long linrec(long long n, long long k, vector<long long> a,
                 vector<long long> b) {
  if (n == 0) return 0;
  if (n <= k) return a[n - 1];
  long long i, j;
  vector<long long> F1(k + 1);
  for (i = 1; i <= k; i++) F1[i] = a[i - 1];
  vector<vector<long long>> T(k + 1, vector<long long>(k + 1));
  for (i = 1; i <= k; i++) {
    for (j = 1; j <= k; j++) {
      if (i < k) {
        if (j == i + 1)
          T[i][j] = 1;
        else
          T[i][j] = 0;
        continue;
      }
      T[i][j] = b[k - j];
    }
  }
  T = matexp(T, n - 1);
  long long res = 0;
  for (i = 1; i <= k; i++) {
    res += (T[1][i] * F1[i]) % 1000000007;
  }
  return res % 1000000007;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long flg = 0;
  long long a[n], p, x, i;
  for (i = 0; i < n; i++) a[i] = -1;
  for (i = 0; i < m; i++) {
    cin >> p >> x;
    if (a[p - 1] >= 0) {
      if (a[p - 1] != x) flg = 1;
    } else
      a[p - 1] = x;
  }
  if (flg || a[0] == 0)
    cout << -1 << '\n';
  else {
    for (i = 0; i < n; i++) {
      if (a[i] == -1) {
        if (i > 0)
          cout << 0;
        else
          cout << 1;
      } else
        cout << a[i];
    }
    cout << "\n";
  }
  return 0;
}
