#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<Pi> c;
  for (long long i = 0; i < (long long)M; i++) {
    int f, s;
    cin >> f >> s;
    if (N > 1 && f == 1 && s == 0) {
      cout << -1 << endl;
      return 0;
    }
    c.push_back(make_pair(f - 1, s));
  }
  sort(c.begin(), c.end());
  vector<int> ans(N, -1);
  for (long long j = 0; j < (long long)M; j++) {
    if (ans.at(c[j].first) != -1 && ans.at(c[j].first) != c[j].second) {
      cout << -1 << endl;
      return 0;
    } else {
      ans.at(c[j].first) = c[j].second;
    }
  }
  for (long long k = 0; k < (long long)N; k++) {
    if (ans[k] == -1) {
      ans[k] = N == 1 || k == 0 ? 0 : 1;
    }
    cout << ans[k];
  }
  cout << endl;
  return 0;
}
