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