#include <bits/stdc++.h>
int main(void) {
  int n, m;
  std::cin >> n >> m;
  bool flag = false;
  std::vector<int> a(n, -1);
  int s, c;
  for (int i = 0; i < m; i++) {
    std::cin >> s >> c;
    if (a[s - 1] == -1 || a[s - 1] == c) {
      a[s - 1] = c;
    } else {
      std::cout << -1 << std::endl;
      return -1;
    }
  }
  if (a[0] > 0) {
  } else if (a[0] == -1 && n != 1) {
    a[0] = 1;
  } else if (a[0] <= 0 && n == 1) {
    std::cout << 0 << std::endl;
    return -1;
  } else {
    std::cout << -1 << std::endl;
    return -1;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] > 0) {
    } else {
      a[i] = 0;
    }
  }
  for (auto i : a) {
    std::cout << i << "";
  }
  std::cout << std::endl;
  return 0;
}
