#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pii> v;
  for (int i = 0; i < (m); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    v.emplace_back(s, c);
  }
  int i = n == 1 ? 0 : pow(10, n - 1);
  int e = pow(10, n);
  while (i < e) {
    string s = to_string(i);
    bool ok = true;
    for (int j = 0; j < (m); j++) {
      if (s[v[j].first] != v[j].second + '0') ok = false;
    }
    if (ok) {
      cout << s << '\n';
      return 0;
    }
  }
  cout << (-1) << '\n';
  return 0;
}
