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