#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  char ar[n];
  for (int i = 0; i < n; i++) ar[i] = '/';
  int flag = 0;
  for (int i = 0; i < m; i++) {
    int me = 0;
    char ae = 0;
    cin >> me;
    cin >> ae;
    if (ar[me - 1] != '/' and ar[me - 1] != ae) {
      flag = 1;
    } else {
      ar[me - 1] = ae;
    }
  }
  for (int i = 0; i < n; i++) {
    if (ar[i] == '/' and i == 0)
      ar[i] = '1';
    else if (ar[i] == '/')
      ar[i] = '0';
  }
  if (flag > 0 or (ar[0] == '0' and n > 1))
    cout << -1;
  else {
    for (int i = 0; i < n; i++) {
      cout << ar[i];
    }
  }
}
