#include <bits/stdc++.h>
using namespace std;
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;
}
const long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
int main() {
  long long n, m;
  cin >> n >> m;
  long long s[m], c[m];
  for (long long i = 0; i < (m); i++) cin >> s[i] >> c[i];
  for (long long i = 1 * pow(10, n - 1); i < (pow(10, n)); i++) {
    string t = to_string(i);
    bool e = true;
    for (long long j = 0; j < (m); j++) {
      if (t[s[j] - 1] != (char)(c[j] + '0')) e = false;
    }
    if (e) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
