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