#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void) {
  int N, M, s;
  string S;
  char C;
  map<ll, bool> check;
  bool ans = true;
  cin >> N >> M;
  if (N > 0) {
    S = "1";
  } else {
    S = "0";
  }
  for (ll i = 1; i < N; i++) {
    S = S + "0";
  }
  for (ll i = 0; i < M; i++) {
    cin >> s >> C;
    if (check[s - 1] == true && S[s - 1] != C) {
      ans = false;
    }
    check[s - 1] = true;
    S[s - 1] = C;
  }
  if (S.size() > 1 && S[0] == '0') {
    ans = false;
  }
  if (ans) {
    cout << S << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
