#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > s(m);
  for (int i = 0; i < ((int)m); i++) cin >> s[i].first >> s[i].second;
  if (m == 0) {
    cout << 1;
    for (int i = 0; i < ((int)n - 1); i++) cout << 0;
    cout << endl;
    return 0;
  }
  (sort(s.begin(), s.end()),
   s.resize(distance(s.begin(), unique(s.begin(), s.end()))));
  if (s[0].first == 1 && s[0].second == 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<long long> ans(n, -1);
  for (int i = 0; i < ((int)s.size()); i++) {
    long long index = s[i].first - 1;
    long long v = s[i].second;
    if (n <= index) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[index] == -1) {
      ans[index] = v;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < ((int)n); i++) {
    if (i == 0 && ans[i] == -1) cout << 1 << endl;
    if (ans[i] == -1)
      cout << 0;
    else
      cout << ans[i];
  }
  cout << endl;
}
