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