#include <bits/stdc++.h>
void solve() {
  int n;
  std::cin >> n;
  std::vector<int> ans(n, -1);
  int m;
  std::cin >> m;
  while (m--) {
    int i, c;
    std::cin >> i >> c;
    --i;
    if (ans[i] != -1 && ans[i] != c) {
      std::cout << "-1" << std::endl;
      return;
    }
    ans[i] = c;
  }
  if (n > 1 && ans[0] == 0) {
    std::cout << -1 << std::endl;
    return;
  }
  for (int i = 0; i < n; ++i) {
    std::cout << (ans[i] != -1 ? ans[i] : i == 0 ? 1 : 0);
  }
  std::cout << std::endl;
}
int main() {
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);
  solve();
  return 0;
}
