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