#include <bits/stdc++.h>
void no() {
  std::cout << -1 << std::endl;
  exit(0);
}
int main(int argc, char** argv) {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);
  int N, M, s, c, a[11];
  std::cin >> N >> M;
  if (M == 0) {
    std::cout << (N == 1 ? 0 : -1) << std::endl;
    return 0;
  }
  memset(a, -1, sizeof(a));
  for (int i = 0; i < M; i++) {
    std::cin >> s >> c;
    if (N > 1)
      if (s == 1 && c == 0) no();
    if (a[s - 1] != -1)
      if (a[s - 1] != c) no();
    a[s - 1] = c;
  }
  for (int i = 0; i < N; i++)
    if (a[i] == -1) a[i] = i == 0 ? 1 : 0;
  for (int i = 0; i < N; i++) std::cout << a[i];
  std::cout << std::endl;
  return 0;
}
