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