#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > v(m);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    v[i] = {s, c};
  }
  vector<int> k(n);
  for (int i = 0; i < m; i++) {
    k[v[i].first - 1] = v[i].second;
  }
  int ans = 0, keta = n - 1;
  for (int i = 0; i < n; i++) {
    ans += k[i] * (int)pow(10, keta);
    keta--;
  }
  if ((int)to_string(ans).size() == n) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
