#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> query(m);
  for (int i = 0; i < m; i++) cin >> query[i].first >> query[i].second;
  vector<int> ans(n, -1);
  auto solve = [&]() {
    for (auto q : query) {
      auto s = q.first;
      auto c = q.second;
      if (s == 1 and c == 0) return false;
      if (ans[s - 1] != -1 and ans[s - 1] != c) return false;
      ans[s - 1] = c;
    }
    if (ans[0] == -1) ans[0] = 1;
    for (int i = 1; i < n; i++)
      if (ans[i] == -1) ans[i] = 0;
    return true;
  };
  if (not solve()) {
    cout << -1 << endl;
  } else {
    for (auto v : ans) cout << v;
    cout << endl;
  }
  return 0;
}
