#include <bits/stdc++.h>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
long long H, W, sh, sw, gh, gw;
long long dh[4] = {1, 0, -1, 0};
long long dw[4] = {0, 1, 0, -1};
long long ctoi(char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return 0;
  }
}
long long gcd(long long a, long long b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long N, M;
  cin >> N >> M;
  string second = "";
  for (long long i = 0; i < long long(N); i++) {
    second += '#';
  }
  for (long long i = 0; i < long long(M); i++) {
    long long s;
    char c;
    cin >> s >> c;
    if (second[s - 1] == '#' || second[s - 1] == c) {
      second[s - 1] = c;
    } else if (second[s - 1] != '#' && second[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (second[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (second[0] == '#') {
    second[0] = '1';
  }
  for (long long i = 0; i < long long(N); i++) {
    if (second[i] == '#') second[i] = '0';
  }
  cout << second << endl;
}
