#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s = "";
  for (int i = 0; i < n; i++) s += '#';
  while (m--) {
    int i;
    char blank;
    char ch;
    cin >> i >> ch;
    if (s[i - 1] == '#') {
      s[i - 1] = ch;
    }
    if (s[i - 1] != ch) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (s[0] == '0' and n != 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < s.size(); i++) {
    if (i == 0 and s[i] == '#')
      s[i] = '1';
    else if (s[i] == '#') {
      s[i] = '0';
    }
  }
  cout << s << endl;
}
