#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> q(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    q[i] = make_pair(a, b);
  }
  sort(q.begin(), q.end());
  int current_digit = 0;
  vector<int> digit(N, -1);
  for (int i = 0; i < M; i++) {
    if (q[i].first >= N) {
      cout << -1 << endl;
      return 0;
    }
    if (q[i].first == 0 && N > 1 && q[i].second == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (digit[q[i].first] == -1 || digit[q[i].first] == q[i].second) {
      digit[q[i].first] = q[i].second;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (digit[0] == -1) {
    digit[0] = 1;
  }
  for (int i = 1; i < N; i++) {
    if (digit[i] == -1) {
      digit[i] = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << digit[i];
  }
  cout << endl;
}
