#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < (N); ++i) A[i] = -1;
  for (int i = 0; i < (M); ++i) {
    int S, C;
    cin >> S >> C;
    --S;
    if (A[S] == -1)
      A[S] = C;
    else if (A[S] != C) {
      puts("-1");
      return 0;
    }
  }
  if (A[0] == -1)
    A[0] = 1;
  else if (A[0] == 0) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i < N; i++) {
    if (A[i] == -1) A[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    cout << A[i];
  }
  cout << '\n';
  return 0;
}
