#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Type>
struct is_vector : std::false_type {};
template <class ValueType, class Alloc>
struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T>
inline std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
  if (v.empty()) return out;
  constexpr bool is_vector_v = is_vector<T>::value;
  if (is_vector_v)
    for (auto itr = v.begin(); itr != v.end();)
      out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
  else
    for (auto itr = v.begin(); itr != v.end();)
      out << (*itr), out << ((++itr != v.end()) ? " " : "");
  return out;
}
inline void put() {}
template <class T>
inline void put(const T& first) {
  std::cout << first << "\n";
}
template <class T, class... N>
inline void put(const T& first, const N&... rest) {
  std::cout << first << " ";
  put(rest...);
}
inline void putn() {}
template <class T, class... N>
inline void putn(const T& first, const N&... rest) {
  std::cout << first << "\n";
  putn(rest...);
}
int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> res(n, -1);
  vector<int> s(m), c(m);
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (long long i = 0; i < (long long)(m); i++) {
    if (res[s[i]] < 0) {
      res[s[i]] = c[i];
    } else {
      if (res[s[i]] != c[i]) {
        put(-1);
        return 0;
      }
    }
  }
  if (res[0] == 0) {
    put(-1);
    return 0;
  }
  if (res[0] < 0) {
    res[0] = 1;
  }
  for (long long i = (long long)(1); i < (long long)(n); i++) {
    if (res[i] < 0) {
      res[i] = 0;
    }
  }
  for (long long i = 0; i < (long long)(n); i++) {
    cout << res[i];
  }
  put("");
  return 0;
}
