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