#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  string s;
  for (int i = 0; i < n; i++) {
    s += "*";
  }
  for (int i = 0; i < m; i++) {
    int p;
    char c;
    cin >> p >> c;
    if (s.at(p-1) == '*') {
      s.at(p-1) = c;
      continue;
    } else if (s.at(p-1) == c) {
      continue;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0 ; i < n; i++) {
    if (i == 0 && s.at(i) == '*') {
      s.at(i) = '1';
    } else if (s.at(i) == '*') {
      s.at(i) = '0';
    }
  }
  if (s.at(0) == '0') {
    cout << -1 << endl;
    return 0;
  }