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