#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll N = 2e5;
ll a[N];
int main() {
  int N, M;
  int s[4] = {0};
  cin >> N >> M;
  int t, o;
  for (int i = 1; i <= M; i++) {
    scanf("%d %d", &t, &o);
    s[t] = o;
  }
  bool prev_zero = false;
  for (int i = 1; i <= N; i++) {
    if (prev_zero && s[i] == 0) {
      cout << "-1";
      return 0;
    }
    if (s[i] == 0) prev_zero = true;
  }
  for (int i = 1; i <= N; i++) cout << s[i];
  return 0;
}
