#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<char> c(M);
  for (int i = 0; i < M; i++) cin >> s.at(i) >> c.at(i);
  for (int i = 0; i < M; i++) {
    for (int j = i + 1; j < M; j++) {
      if (s.at(i) == s.at(j)) {
        if (c.at(i) != c.at(j)) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
    if (s.at(i) == 1 && c.at(i) == '0') {
      cout << -1 << endl;
      return 0;
    }
  }
  string str(N, '0');
  if (M == 0) {
    if (N == 1) {
      str.at(0) = '0';
      cout << str << endl;
      return 0;
    }
    str.at(0) = '1';
    cout << str << endl;
    return 0;
  }
  for (int i = 0; i < M; i++) {
    str.at(s.at(i) - 1) = c.at(i);
  }
  cout << str << endl;
}
