#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int64_t INF = (1LL << 60);
const long double inf = pow(10, 10);
const long double pi = acosl((long double)1);
const int64_t mod = 1000003;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int64_t get(int64_t n, int64_t k) {
  string s = to_string(n);
  return (s[k] - '0');
}
void solve() {
  int64_t n, m;
  cin >> n >> m;
  int64_t s[m];
  int64_t c[m];
  for (int64_t j = 0; j < (int64_t)(m); j++) {
    cin >> s[j] >> c[j];
    s[j]--;
  }
  for (int64_t i = pow(10, n - 1); i < pow(10, n); i++) {
    bool isOK = true;
    for (int64_t j = 0; j < (int64_t)(m); j++) {
      if (get(i, s[j]) != c[j]) isOK = false;
    }
    if (isOK) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  cout << setprecision(30);
  solve();
}
