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