#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int inf = 1e8;
const long long INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main() {
  int N, M;
  cin >> N >> M;
  string S = "";
  for (int i = 0; i < N; i++) S += 'x';
  for (int i = 0; i < M; i++) {
    int s;
    char c;
    cin >> s >> c;
    if (S[s - 1] != 'x' && S[s - 1] != c) {
      cout << -1 << endl;
      exit(0);
    } else
      S[s - 1] = c;
  }
  if (S[0] == '0') {
    cout << -1 << endl;
    exit(0);
  }
  if (S[0] == 'x') S[0] = '1';
  for (int i = 1; i <= N - 1; i++) {
    if (S[i] == 'x') S[i] = '0';
  }
  cout << S << endl;
}
