#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
void leave(string message) {
  cout << message << endl;
  exit(0);
}
int main() {
  lint n, m;
  cin >> n >> m;
  string num = string(n, '?');
  for (lint i = 0; i < m; i++) {
    lint s;
    char c;
    cin >> s >> c;
    if (num[s - 1] != '?' && num[s - 1] != c) leave("-1");
    num[s - 1] = c;
  }
  if (num[0] == '0') {
    if (n == 1) leave("0");
    leave("-1");
  }
  if (num[0] == '?') num[0] = '1';
  for (lint i = 0; i < n; i++) {
    if (num[i] == '?') num[i] = '0';
  }
  cout << num << endl;
}
