#include <bits/stdc++.h>
using namespace std;
long long M = 1000000007;
long long bin_pow(long long a, long long pow) {
  if (pow == 0) return 1;
  if (pow == 1) return a;
  if (pow % 2 == 0) {
    long long tmp = bin_pow(a, pow / 2) % M;
    return tmp * tmp % M;
  }
  return a * bin_pow(a, pow - 1) % M;
}
long long inv(long long a) { return bin_pow(a, M - 2) % M; }
long long fact(long long a) {
  long long ans = 1;
  for (int i = 1; i <= a; i++) {
    ans *= i;
    ans %= M;
  }
  return ans;
}
vector<vector<int>> d;
vector<pair<int, int>> a;
int ans(int n, int t) {
  if (t <= 0 || n == 0) return 0;
  if (d[n][t] == -1) {
    d[n][t] =
        max(ans(n - 1, t), ans(n - 1, t - a[n - 1].first) + a[n - 1].second);
  }
  return d[n][t];
}
int main() {
  cin.tie();
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  a[0] = m == 0 ? 0 : 1;
  for (int i = 1; i < n; i++) a[i] = 0;
  set<int> was;
  bool ans = true;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if ((was.count(x) == 1 && a[x - 1] != y) || (x == 1 && y == 0 && n != 1)) {
      ans = false;
    }
    was.insert(x);
    a[x - 1] = y;
  }
  if (ans) {
    for (auto aa : a) cout << aa;
  } else {
    cout << -1;
  }
  return 0;
}
