#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 1;
const long long MOD = 1e9 + 7;
template <class T, class S>
std::ostream& operator<<(std::ostream& os, std::pair<T, S> p) {
  return os << "(" << p.first << " " << p.second << ")";
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T> v) {
  for (long long i = 0; i < (long long)v.size(); i++) {
    os << " [" << i << "]" << v[i];
    if (i % 10 == 9) os << std::endl;
  }
  return os;
}
template <class T, class S>
std::ostream& operator<<(std::ostream& os, std::map<T, S> m) {
  long long i = 0;
  for (auto p : m) {
    os << " [" << i << "]" << p.first << "->" << p.second;
    i++;
  }
  return os;
}
template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<std::vector<T> > vv) {
  for (auto& vec : vv) {
    os << vec;
  }
  return os;
}
void print() { std::cout << std::endl; }
template <typename H>
void print(H&& head) {
  std::cout << head << std::endl;
}
template <typename H, typename... T>
void print(H&& head, T&&... tail) {
  std::cout << head << " ", print(std::forward<T>(tail)...);
}
void fail() {
  print(-1);
  std::exit(0);
}
int main() {
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);
  long long N, M;
  std::cin >> N >> M;
  std::vector<int> vc(N, -1);
  std::map<int, int> mc;
  for (long long i = 0; i < M; i++) {
    int s, c;
    std::cin >> s >> c;
    s--;
    if (vc[s] != c && vc[s] != -1) fail();
    vc[s] = c;
  }
  if (vc[0] == 0) fail();
  if (vc[0] == -1) vc[0] = 1;
  std::cout << vc[0];
  for (long long i = 1; i < N; i++) {
    if (vc[i] == -1) vc[i] = 0;
    std::cout << vc[i];
  }
  print();
  return 0;
}
