#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
void solve(long long N, long long M, std::vector<long long> s,
           std::vector<long long> c) {
  vector<ll> ans(N, -1);
  for (ll i = 0; i < (M); ++i) {
    const ll si = s.at(i) - 1;
    const ll ci = c.at(i);
    if (ans.at(si) != -1 && ans.at(si) != ci) {
      cout << -1 << endl;
      return;
    }
    ans.at(si) = ci;
  }
  for (ll i = 0; i < (N); ++i) {
    if (ans.at(i) != -1) {
      continue;
    }
    if (i == 0) {
      ans.at(i) = 1;
    } else {
      ans.at(i) = 0;
    }
  }
  if (ans.at(0) == 0) {
    cout << -1 << endl;
    return;
  }
  for (ll i = 0; i < (N); ++i) {
    cout << ans.at(i);
  }
  cout << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> s(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &s[i]);
    scanf("%lld", &c[i]);
  }
  solve(N, M, std::move(s), std::move(c));
  return 0;
}
