#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  vector<ll> s(m), c(m);
  vector<bool> flag(n + 1, false);
  for (ll i = 0; i < m; i++) {
    ll s, c;
    cin >> s >> c;
    if (!flag[s]) {
      for (ll j = 0; j < n - s; j++) {
        c *= 10;
      }
      ans += c;
      flag[s] = true;
    }
  }
  if (n == 1 && ans == 0) {
    cout << ans << endl;
    return 0;
  }
  ll tmp = ans;
  ll dig = 0;
  while (tmp > 0) {
    tmp /= 10;
    dig++;
  }
  if (dig == n) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}
