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