#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 INF = 1LL << 60;
const long long MOD = 1000000007;
long long getDigit(long long n) {
  long long cnt = 0;
  while (n != 0) {
    n /= 10;
    cnt++;
  }
  return cnt;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool comp(const pair<double, long long>& a, const pair<double, long long>& b) {
  if (a.first == b.first)
    return a.second > b.second;
  else {
    return a.first > b.first;
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> s(m), c(m);
  for (long long i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  for (long long ans = pow(10, n - 1); ans <= 999; ans++) {
    string tmpS = to_string(ans);
    bool flag = true;
    for (long long i = 0; i < m; i++) {
      if (tmpS[s[i] - 1] != '0' + c[i]) flag = false;
    }
    if (flag == true) return cout << ans << endl, 0;
  }
  cout << -1 << endl;
}
