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