#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  size_t n = vec.size();
  for (size_t i = 0; i < n; ++i) {
    os << vec[i];
    if (i != n - 1) os << ',';
  }
  os << '}';
  return os;
}
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  os << '{';
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    os << '{' << it->first << ':' << it->second << '}';
    if (it != --mp.end()) os << ',';
  }
  os << '}';
  return os;
}
template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  os << '{';
  for (auto it = st.begin(); it != st.end(); ++it) {
    os << *it;
    if (it != --st.end()) os << ',';
  }
  os << '}';
  return os;
}
template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  size_t n = vec.size();
  for (size_t i = 0; i < n; ++i) is >> vec[i];
  return is;
}
void debug_out() { std::cerr << '\n'; }
template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> num(10, -1);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    --s;
    if (num[s] == -1) {
      if (n > 1 && s == 0 && c == 0) {
        cout << -1 << endl;
        return 0;
      } else {
        num[s] = c;
      }
    } else {
      if (num[s] != c) {
        cout << -1 << endl;
        return 0;
      } else {
        ;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (num[i] == -1) {
      if (i == 0) {
        cout << 1;
      } else {
        cout << 0;
      }
    } else {
      cout << num[i];
    }
  }
  cout << endl;
  return 0;
}
