#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
signed main() {
  long long x = 0, y = 0, z = 0, w = 0, n = 0, m = 0;
  std::cin >> x >> y;
  std::vector<long long> v(x, -1);
  for (long long i = 0; i < (long long)(y); ++i) {
    std::cin >> z >> w;
    if (z == 1 && w == 0) {
      std::cout << -1 << '\n';
      return 0;
    }
    if (v[z - 1] < 0 || v[z - 1] == w) {
      v[z - 1] = w;
    } else {
      std::cout << -1 << '\n';
      return 0;
    }
  }
  for (long long i = 0; i < (long long)(x); ++i) {
    if (v[i] >= 0)
      std::cout << v[i];
    else if (i == 0)
      std::cout << 1;
    else
      std::cout << 0;
  }
  std::cout << '\n';
}
