#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int S[M];
  char C[M];
  for (int i = 0; i < (M); ++i) cin >> S[i] >> C[i];
  for (int i = pow(10, N - 1); i < pow(10, N); i++) {
    string si = to_string(i);
    bool ok = true;
    for (int mi = 0; mi < M; mi++) {
      ok &= si[S[mi] - 1] == C[mi];
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}
