#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename KeyType, typename ValueType>
std::pair<KeyType, ValueType> get_max(const std::map<KeyType, ValueType>& x) {
  using pairtype = std::pair<KeyType, ValueType>;
  return *std::max_element(x.begin(), x.end(),
                           [](const pairtype& p1, const pairtype& p2) {
                             return p1.second < p2.second;
                           });
}
using namespace std;
using P = pair<int, int>;
using ll = long long;
const ll INF = 1LL << 60;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  for (int i = 0; i < (m); ++i) {
    int p, q;
    cin >> p >> q;
    --p;
    if (a[p] != -1 && a[p] != q) {
      cout << -1 << endl;
      return 0;
    }
    a[p] = q;
  }
  for (int i = 0; i < n; i++) {
    if (i == 0 && a[i] == -1) {
      a[i] = 1;
    }
    if (a[i] == -1) {
      a[i] = 0;
    }
  }
  if (a[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (auto v : a) cout << v;
  cout << endl;
  return 0;
}
