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