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