#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
int main() {
  int n, m, i, a;
  bool f = 0;
  char b;
  cin >> n >> m;
  string s(n, 'a');
  while (m--) {
    cin >> a >> b;
    if (s[a - 1] != 'a' && s[a - 1] != b) {
      cout << -1 << '\n';
      return 0;
    }
    s[a - 1] = b;
  }
  if (s[0] == 'a') s[0] = '1';
  for (i = 1; i < n; i++) {
    if (s[i] == 'a') {
      s[i] = '0';
    }
  }
  if (s[0] == '0') {
    cout << -1 << '\n';
  } else
    cout << s << '\n';
}
