#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
inline int std_in(int& a) { return scanf("%d", &a); }
auto pint_compare = [](pint x, pint y) -> bool { return (x.first < y.first); };
const int MOD = 1000000007;
int pow10(int n) {
  int ret = 1;
  for (int(i) = 0; (i) < (n); ++(i)) ret *= 10;
  return ret;
}
signed main() {
  int N, M, s[3], c[5];
  cin >> N >> M;
  for (int(i) = 0; (i) < (M); ++(i)) cin >> s[i] >> c[i];
  for (int i = pow10(N - 1); i < pow10(N); i++) {
    bool flag = true;
    for (int(j) = 0; (j) < (M); ++(j)) {
      if ((i / pow10(N - s[j])) % 10 != c[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << (i) << "\n";
      return 0;
    }
  }
  cout << ("-1") << "\n";
  return 0;
}
