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