#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) std::swap(a, b);
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a * b / g;
}
int N, M;
string S = "";
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    S += '.';
  }
  for (int i = 0; i < M; i++) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if (S[s] == '.' || S[s] == c) {
      S[s] = c;
    } else {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '.') S[i] = '0';
  }
  if (S[0] == '0') {
    if (S.length() == 1) {
      cout << 0;
      return 0;
    }
    cout << -1;
    return 0;
  } else {
    cout << S;
    return 0;
  }
}
