#include <bits/stdc++.h>
using namespace std;
const long long dx[] = {1, 0, -1, 0, 1, 1, -1, -1},
                dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
const long long MOD = 1e9 + 7;
template <typename T>
inline T GCD(T a, T b) {
  T c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <typename T>
inline T LCM(T a, T b) {
  T c = GCD(a, b);
  a /= c;
  return a * b;
}
template <typename T>
inline T nCr(T a, T b) {
  T i, r = 1;
  for (i = 1; i <= b; i++) {
    r *= (a + 1 - i);
    r /= i;
  }
  return r;
}
template <typename T>
inline T nHr(T a, T b) {
  return nCr(a + b - 1, b);
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct edge2 {
  long long to, cost;
};
struct edge3 {
  long long from, to, cost;
};
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  long long s[5];
  char c[5];
  for (long long i = 0; i < (M); ++i) {
    cin >> s[i] >> c[i];
  }
  for (long long i = pow(10, N - 1); i < pow(10, N); i++) {
    string S = to_string(i);
    bool ok = 1;
    for (long long j = 0; j < (M); ++j) {
      ok &= (S[s[j] - 1] == c[j]);
    }
    if (ok) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
}
