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