#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for (int i = 0; i < M; ++i) cin >> s[i] >> c[i];
  vector<int> ans(N, -1);
  for (int i = 0; i < M; ++i) {
    if (ans[s[i]] != -1 && ans[s[i]] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans[s[i]] = c[i];
  }
  for (int i = 0; i < N; ++i) {
    if (ans[i] != -1) continue;
    ans[i] = i == 0 ? 1 : 0;
  }
  for (const auto elem : ans) cout << elem;
  cout << endl;
}
