#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[M];
  int c[M];
  vector<int> ans(N, -1);
  bool sw = true;
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = 0; i < M; i++) {
    if (s[i] == 1 && c[i] == 0) {
      sw = false;
      break;
    }
    if (ans[s[i] - 1] != -1 && ans[s[i] - 1] != c[i]) {
      sw = false;
      break;
    }
    ans[s[i] - 1] = c[i];
  }
  if (sw == true) {
    if (ans[0] == -1) ans[0] = 1;
    if (ans[1] == -1) ans[1] = 0;
    if (ans[2] == -1) ans[2] = 0;
    for (int i = 0; i < N; i++) {
      cout << ans[i];
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
}
