#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll atcoder_mod = 1e9 + 7;
template <typename T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}
template <typename T = int, typename C = vector<T>>
C vecin(int N) {
  C x(N);
  for (int i = 0; i < (N); ++i) {
    x[i] = in<T>();
  }
  return move(x);
}
void vout() { cout << endl; }
template <typename Head, typename... Tail>
void vout(Head&& h, Tail&&... t) {
  cout << ' ' << h;
  vout(forward<Tail>(t)...);
}
void out() { cout << endl; }
template <typename Head, typename... Tail>
void out(Head&& h, Tail&&... t) {
  cout << h;
  vout(forward<Tail>(t)...);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N = in(), M = in();
  vector<int> P(N, -1);
  for (int i = 0; i < (M); ++i) {
    int s = in(), c = in();
    if (c == 0 && N > 1) {
      out(-1);
      return 0;
    }
    if (P[s - 1] != -1) {
      if (P[s - 1] != c) {
        out(-1);
        return 0;
      }
    }
    P[s - 1] = c;
  }
  for (int i = 0; i < (N); ++i) {
    if (P[i] == -1) {
      if (!i && N > 1)
        P[i] = 1;
      else
        P[i] = 0;
    }
    cout << P[i];
  }
  out();
  return 0;
}
