#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  std::string s(n, '*');
  for (int i = 0; i < m; ++i) {
    int id;
    char c;
    std::cin >> id >> c;
    --id;
    if (s[id] == '*' or (s[id] == c)) {
      s[id] = c;
    } else {
      return puts("-1") * 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      if (s[i] == '0') return puts("-1") * 0;
      if (s[i] == '*') s[i] = '1';
    } else {
      s[i] = s[i] == '*' ? '0' : s[i];
    }
  }
  std::cout << s << std::endl;
}
