#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M, s, c;
  cin >> N >> M;
  vector<long long> num(N, -1);
  for (long long i = 0; i < M; i++) {
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    } else if (num[s] == -1) {
      num[s] = c;
    } else if (num[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (num[0] == -1) {
    num[0] = 1;
  }
  for (long long i = 1; i < N; i++) {
    if (num[i] == -1) num[i] = 0;
  }
  for (long long i = 0; i < N; i++) {
    cout << num[i];
  }
}
