#include <bits/stdc++.h>
using namespace std;
struct mint {
  long long x;
  static const int MOD = 1000000007;
  mint(long long x = 0) : x(x % MOD) {}
  void operator=(const long long n) { x = n % MOD; }
  mint operator+(const mint n) {
    mint ret;
    ret.x = (x + n.x) % MOD;
    return ret;
  }
  mint operator-(const mint n) {
    mint ret;
    ret.x = (x - n.x + MOD) % MOD;
    return ret;
  }
  mint operator*(const mint n) {
    mint ret;
    ret.x = (x * n.x) % MOD;
    return ret;
  }
  mint operator/(const mint n) {
    mint ret;
    ret.x = (x * n.inv().x) % MOD;
    return ret;
  }
  mint inv() const {
    mint ret;
    long long a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    ret.x = u;
    return ret;
  }
};
mint mpow(mint a, int n) {
  mint ret = 1;
  while (n > 0) {
    if (n & 1) ret = ret * a;
    a = a * a;
    n >>= 1;
  }
  return ret;
}
void factorial(vector<mint>& fact) {
  for (int i = 0; i < fact.size(); i++) {
    if (i == 0 || i == 1)
      fact[i] = 1;
    else
      fact[i] = fact[i - 1] * i;
  }
}
mint c(int n, int a, vector<mint>& fact) {
  return fact[n] / (fact[a] * fact[n - a]);
}
void p(int n, int max_a, vector<mint>& perm) {
  for (int i = 0; i <= max_a; i++) {
    if (i == 0)
      perm[i] = 1;
    else
      perm[i] = perm[i - 1] * (n - i + 1);
  }
}
ostream& operator<<(ostream& os, const mint& n) {
  os << n.x;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n, m;
  cin >> n >> m;
  vector<int> num;
  for (int i = 0; i < n; i++) {
    num.push_back(-1);
  }
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (num[s] == -1) {
      if (s == 0 && c == 0 && n > 2) {
        cout << -1 << endl;
        return 0;
      } else {
        num[s] = c;
      }
    } else if (num[s] != -1 && num[s] == c) {
      continue;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (num[i] == -1) {
      if (i == 0)
        num[i] = 1;
      else
        num[i] = 0;
    }
    cout << num[i];
  }
  cout << endl;
  return 0;
}
