#include <bits/stdc++.h>
using namespace std;
long long N, M;
int main() {
  cin >> N >> M;
  string str;
  for (int i = 0; i < N; i++) {
    if (i == 0)
      str += '-';
    else
      str += '-';
  }
  bool ans = true;
  for (int i = 0; i < M; i++) {
    int s;
    char c;
    cin >> s >> c;
    if (s == 1 && c == '0') ans = false;
    if (str[s - 1] != '-' && str[s - 1] != c) ans = false;
    str[s - 1] = c;
  }
  for (int i = 0; i < N; i++) {
    if (str[i] == '-') {
      if (i == 0)
        str[i] = '1';
      else
        str[i] = '0';
    }
  }
  cout << (ans ? str : "-1") << endl;
  return 0;
}
