#include <bits/stdc++.h>
using namespace std;
template <class T>
using MINPQ = std::priority_queue<T, vector<T>, greater<T>>;
template <class T>
using MAXPQ = std::priority_queue<T>;
const long long hmod1 = 999999937;
const long long hmod2 = 1000000000 + 9;
const long long INF = 1 << 30;
const long long INFLL = 1LL << 62;
const long double EPS = 1e-12;
const long long mod = 1000000000 + 7;
const long long dx4[4] = {1, 0, -1, 0};
const long long dy4[4] = {0, 1, 0, -1};
const long long dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const long long dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const long double pi = 3.141592653589793;
void dump_func() { cerr << endl; };
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
  cerr << head;
  if (sizeof...(Tail) == 0)
    cerr << " ";
  else
    cerr << ", ";
  dump_func(std::move(tail)...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  for (long long i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
  os << "[";
  for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
    os << "(" << itr->first << ", " << itr->second << ")";
    itr++;
    if (itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "]";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
  os << "[";
  for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
    os << *itr;
    ++itr;
    if (itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "]";
  return os;
}
long long n, m;
long long d[3];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  cin >> m;
  for (long long i = 0; i < (3); i++) d[i] = -1;
  for (long long i = 0; i < (m); i++) {
    long long s, c;
    cin >> s >> c;
    s--;
    if (d[s] != -1 && d[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    d[s] = c;
  }
  if (d[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  string ans = "";
  for (long long i = 0; i < (n); i++) {
    if (d[i] == -1) {
      if (i == 0)
        ans += "1";
      else
        ans += "0";
    } else {
      ans += d[i] + '0';
    }
  }
  cout << ans << endl;
}
