#include <bits/stdc++.h>
using namespace std;
long long arr[200001];
long long nChoosek(long long n, long long k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  long long result = n;
  for (long long i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
long long choose2(long long n) { return n * (n - 1) / 2; }
long long num[3]{-1};
int32_t main() {
  long long N, M;
  cin >> N >> M;
  for (long long i = 0; i < M; i++) {
    long long s, c;
    cin >> s >> c;
    if (num[s - 1] != -1) {
      cout << "-1" << endl;
      return 0;
    }
    num[s - 1] = c;
  }
  if (num[0] == 0 && N > 1) {
    cout << "-1" << endl;
  } else {
    for (long long i = 0; i < N; i++) {
      cout << num[i];
    }
  }
}
