#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long long MAX_N = 200100;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long memo[3];
  for (long long i = 0; i < 3; i++) {
    memo[i] = -1;
  }
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    if (a == 1 && b == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (memo[a - 1] != -1) {
      if (memo[a - 1] != b) {
        cout << -1 << endl;
        return 0;
      }
    } else
      memo[a - 1] = b;
  }
  for (long long i = 0; i < n; i++) {
    long long t = memo[i + 3 - n];
    if (t == -1 && i == 0)
      t = 1;
    else if (t == -1)
      t = 0;
    cout << t;
  }
  cout << endl;
  return 0;
}
