#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<char> k(n, ' ');
  for (int i = 0; i < m; i++) {
    int s;
    char c;
    cin >> s >> c;
    if (s > n) {
      cout << "-1" << endl;
      return 0;
    }
    if (k.at(s - 1) != ' ' && k.at(s - 1) != c) {
      cout << "-1" << endl;
      return 0;
    }
    if (n > 1 && s == 1 && c == '0') {
      cout << "-1" << endl;
      return 0;
    }
    k.at(s - 1) = c;
  }
  if (k.at(0) == ' ') {
    if (n == 1) {
      k.at(0) = '0';
    } else {
      k.at(0) = '1';
    }
  }
  if (n > 1) {
    for (int i = 0; i < n; i++) {
      if (k.at(i) == ' ') {
        k.at(i) = 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << k.at(i);
  }
  cout << endl;
  return 0;
}
