#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> S(M), C(M);
  vector<i64> ans(N, -1);
  rep(i,0,M) {
    cin >> S[i] >> C[i];
    S[i]--;
    if(ans[S[i]] == -1 || (ans[S[i]] == C[i])) {
      ans[S[i]] = C[i];
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  i64 OK = false;
  rep(i,0,N) {
    if(ans[i] == -1) {
      if(OK) ans[i] = 0;
      else ans[i] = 1;
      OK = true;
    }
  }
  if(count(all(ans), 0) == N) {
    cout << -1 << endl;
    return 0;
  }
  rep(i,0,N) {
    cout << ans[i];
  }
  cout << endl;
}
