#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) is >> x;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (long long i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
  for (long long i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << endl;
    os << v[i];
  }
  return os;
}
const int md = 1000000007;
const int INF = 1 << 30;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> ma;
  bool f = true;
  for (long long i = (0), __last_i = (m); i < __last_i; i++) {
    int s, t;
    cin >> s >> t;
    s--;
    if (ma.count(s) and ma[s] != t) f = false;
    ma[s] = t;
  }
  if (!f or (n >= 2 and ma[0] == 0)) {
    cout << -1 << endl;
    return 0;
  }
  string ans = "1";
  ans.resize(n, '0');
  for (long long i = (0), __last_i = (n); i < __last_i; i++) {
    if (ma.count(i) > 0) {
      ans[i] = (ma[i] + '0');
    }
  }
  cout << ans << endl;
}
