#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<char> S(N, ' ');
  for (int ii = 0; ii < M; ii++) {
    int s;
    char c;
    cin >> s >> c;
    if (S[s - 1] == c) continue;
    if (S[s - 1] != ' ') {
      cout << -1 << endl;
      return 0;
    }
    S[s - 1] = c;
  }
  if (S[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (S[0] == ' ') {
    S[0] = '1';
  }
  for (auto& c : S) {
    if (c == ' ') {
      c = '0';
    }
  }
  for (auto& c : S) {
    cout << c;
  }
  cout << endl;
  return 0;
}
