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