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