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