#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll LINF = 1001002003004005006ll;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int num = 1;
  int n, m;
  cin >> n >> m;
  int idx[m], c[m];
  for (int i = 0; i < (m); i++) cin >> idx[i] >> c[i];
  for (int i = 0; i < (n - 1); i++) num *= 10;
  for (int x = num; x < num * 10; x++) {
    string s = to_string(x);
    bool f = true;
    for (int i = 0; i < (m); i++) {
      if (s[idx[i] - 1] == (char)('0' + c[i])) continue;
      f = false;
    }
    if (f) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
