#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> tbl(N, -1);
  bool ans = true;
  for (ll i = (0); i < (M); ++i) {
    ll s, c;
    cin >> s >> c;
    if (tbl.at(s - 1) == c || tbl.at(s - 1) == -1) {
      tbl.at(s - 1) = c;
    } else {
      ans = false;
      break;
    }
  }
  if (ans) {
    for (ll i = (0); i < (tbl.size()); ++i) {
      if (tbl.at(i) < 0) {
        tbl.at(i) = i == 0 ? 1 : 0;
      }
    }
  }
  if (tbl.at(0) == 0) ans = false;
  if (ans) {
    for (auto &&t : tbl) {
      cout << t;
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
