#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long infll = (1LL << 62) - 1;
const long long inf = (1LL << 30) - 1;
template <class S, class T>
inline bool chmax(S &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class S, class T>
inline bool chmin(S &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v(m);
  for (long long i = 0; i < m; ++i) cin >> v[i].first >> v[i].second;
  for (long long i = pow(10, n - 1); i <= pow(10, n); ++i) {
    string s = to_string(i);
    int cnt = 0;
    for (long long j = 0; j < m; ++j)
      if (s[v[j].first - 1] - '0' == v[j].second) ++cnt;
    if (cnt == m) {
      cout << s << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
}
