#include <bits/stdc++.h>
using VI = std::vector<long long>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<long long, long long>;
template <typename T>
void container_union(T &c1, T &c2, T &c3) {
  std::vector<long long> vec;
  std::set_union(c1.begin(), c1.end(), c2.begin(), c2.end(),
                 std::back_inserter(vec));
  T tmp(vec.begin(), vec.end());
  c3 = tmp;
}
template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long LIS(std::vector<long long> &v, long long INF) {
  long long n = ((long long)(v).size());
  VI dp(n, INF);
  for (long long i = (0); i < (n); i++) {
    *std::lower_bound(dp.begin(), dp.end(), v.at(i)) = v.at(i);
  }
  return std::lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}
long long LIS2D(std::vector<PII> &v, long long INF) {
  long long n = ((long long)(v).size());
  for (long long i = (0); i < (n); i++) {
    v.at(i).second *= -1;
  }
  std::sort((v).begin(), (v).end());
  VI snd(n);
  for (long long i = (0); i < (n); i++) {
    v.at(i).second *= -1;
    snd.at(i) = v.at(i).second;
  }
  return LIS(snd, INF);
}
std::vector<long long> dx = {1, -1, 0, 0};
std::vector<long long> dy = {0, 0, 1, -1};
std::string yes = "Yes";
std::string no = "No";
std::string YES = "YES";
std::string NO = "NO";
void solve();
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(10);
  solve();
  return 0;
}
void solve() {
  std::string res = "";
  long long n, m;
  long long s, c;
  std::set<PII> set;
  long long lasts = 0;
  std::cin >> n >> m;
  for (long long i = (0); i < (m); i++) {
    std::cin >> s >> c;
    set.insert(PII(s, c));
    if (s == 1 && c == 0 && n != 1) {
      res = "-1";
      goto END;
    }
  }
  for (auto iter : set) {
    std::tie(s, c) = iter;
    if (s == lasts) {
      res = "-1";
      goto END;
    }
    if (s != lasts + 1) {
      for (long long i = (0); i < (s - lasts - 1); i++) {
        res += "0";
      }
    }
    res += std::to_string(c);
    lasts = s;
  }
  if (((long long)(res).size()) > n) {
    res = "-1";
  } else if (((long long)(res).size()) == n) {
    if (res.at(0) == '0') {
      res.at(0) = '1';
    }
  } else {
    if (((long long)(res).size()) == 0 && n != 1) {
      res += "1";
    }
    while (((long long)(res).size()) < n) {
      res += "0";
    }
  }
END:
  std::cout << res << '\n';
}
