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