#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> s_c(M);
  for (int i = 0; i < M; i++) {
    cin >> s_c.at(i).first >> s_c.at(i).second;
  }
  char S[N + 1];
  for (int i = 0; i < N; i++) {
    S[i] = 'a';
  }
  S[N] = '\0';
  for (int i = 0; i < M; i++) {
    int point, number;
    tie(point, number) = s_c.at(i);
    if (point > N) {
      cout << "-1" << endl;
      return 0;
    }
    if (point == 1 && number == 0) {
      cout << "-1" << endl;
      return 0;
    }
    if (S[point - 1] == 'a' || S[point - 1] == number + '0') {
      S[point - 1] = number + '0';
    } else {
      cout << "-1" << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (S[i] == 'a') S[i] = '0';
  }
  cout << S << endl;
}
