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