#include <bits/stdc++.h>
int main() {
  int n, m, s, c, ans = 0;
  std::cin >> n >> m;
  std::vector<int> a(n, -1);
  for (int i = 0; i < m; i++) {
    std::cin >> s >> c;
    if (a[s - 1] == -1 or a[s - 1] == c) {
      a[s - 1] = c;
    } else {
      ans = -1;
    }
  }
  if (ans == 0) {
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) {
        if (i == 0) {
          a[i] = 1;
        } else {
          a[i] = 0;
        }
      }
      ans += a[i] * (int)std::pow(10, (n - i - 1));
    }
  }
  if (a[0] == 0 and n >= 2) {
    ans = -1;
  }
  std::cout << ans << std::endl;
  return 0;
}
