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