#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
const int Mod = 1E9 + 7;
inline void yes() { std::cout << "Yes\n"; }
inline void no() { std::cout << "No\n"; }
template <typename T, typename U>
inline bool exist(T val, U &any) {
  return any.find(val) != any.end();
}
template <typename TAIL>
inline void inp(TAIL &T) {
  cin >> T;
}
template <typename HEAD, typename... TAIL>
inline void inp(HEAD &H, TAIL &...T) {
  cin >> H;
  inp(T...);
}
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T, U> &a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
  for (auto &x : a) in >> x;
  return in;
}
void solve(int &T) {
  long long int n;
  std::cin >> n;
  vector<long long int> a(n + 1, -1);
  long long int m;
  std::cin >> m;
  for (long long int i = (0); i < (m); i++) {
    long long int x, y;
    std::cin >> x >> y;
    if (a[x] == -1)
      a[x] = y;
    else if (a[x] != y) {
      std::cout << -1 << '\n';
      return;
    }
  }
  if (n != 1 and a[1] == 0) {
    std::cout << -1 << '\n';
    return;
  }
  long long int first = 1;
  for (long long int i = (1); i < (n + 1); i++) {
    if (a[i] == -1) a[i] = first;
    first = 0;
  }
  for (long long int i = (1); i < (n + 1); i++) std::cout << a[i];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) solve(t);
  return 0;
}
