#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  if (M == 0 || M == 4 || M == 5) {
    cout << "-1" << endl;
    return 0;
  }
  int T[N], s, c;
  for (int i = 0; i < N; i++) {
    T[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    if (T[s - 1] > 0) {
      cout << "-1" << endl;
      return 0;
    } else {
      T[s - 1] = c;
    }
  }
  if (T[0] == 0) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    cout << T[i];
  }
  cout << endl;
}
