#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, m;
  cin >> n >> m;
  int aa[m];
  char bb[m];
  string z;
  z += '_';
  s += '1';
  for (int i = 1; i < n; i++) {
    s += '0';
    z += '_';
  }
  for (int i = 0; i < m; i++) {
    cin >> aa[i] >> bb[i];
    s[aa[i] - 1] = bb[i];
  }
  for (int i = 0; i < m; i++) {
    if (z[aa[i] - 1] == '_' || z[aa[i] - 1] == bb[i])
      z[aa[i] - 1] = bb[i];
    else {
      cout << "-1\n";
      return 0;
    }
  }
  int a;
  int digit = 0;
  a = stoi(s);
  if (a > 0) {
    while (a > 0) {
      a /= 10;
      digit++;
    }
  } else
    digit = 1;
  if (digit == n)
    cout << s << endl;
  else
    cout << "-1\n";
}
