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