#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using namespace std;
bool isPrimeNum(ll x) {
  if (x <= 1) {
    return false;
  }
  int n = (int)sqrt((double)x);
  for (int i = 2; i <= n; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
ll myPow(ll x, ll n, ll m) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll abs(ll a, ll b) {
  if (a >= b) return a - b;
  if (a < b) return b - a;
}
constexpr double dabs(double a, double b) {
  if (a >= b) return a - b;
  if (a < b) return b - a;
}
constexpr ll min(ll a, ll b) {
  if (a >= b) return b;
  if (a < b) return a;
}
constexpr ll max(ll a, ll b) {
  if (a >= b) return a;
  if (a < b) return b;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx8[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
class UnionFind {
 public:
  vector<int> Parent;
  UnionFind(int N) { Parent = vector<int>(N, -1); }
  int root(int A) {
    if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  int size(int A) { return -Parent[root(A)]; }
  bool issame(int x, int y) { return root(x) == root(y); }
  bool connect(int A, int B) {
    A = root(A);
    B = root(B);
    if (A == B) {
      return false;
    }
    if (size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
};
long long fac[510000], finv[510000], inv[510000];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < 510000; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    inv[i] = 1000000007 - inv[1000000007 % i] * (1000000007 / i) % 1000000007;
    finv[i] = finv[i - 1] * inv[i] % 1000000007;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % 1000000007) % 1000000007;
}
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
void yn(bool flag) {
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return;
}
void YN(bool flag) {
  if (flag) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return;
}
std::vector<ll> enum_div(ll n) {
  std::vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != 1 && i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  ret.push_back(n);
  return ret;
}
struct Edge {
  ll to;
  ll weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<ll>>;
template <class V, int NV>
struct SegTree {
  V comp(V &l, V &r) { return max(l, r); };
  vector<V> val;
  SegTree() { val = vector<V>(NV * 2, 0); }
  V get(int x, int y, int l = 0, int r = NV, int k = 1) {
    if (r <= x || y <= l) return 0;
    if (x <= l && r <= y) return val[k];
    auto a = get(x, y, l, (l + r) / 2, k * 2);
    auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
    return comp(a, b);
  }
  void update(int i, V v) {
    i += NV;
    val[i] = v;
    while (i > 1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
  }
  void add(int i, V v) { update(i, val[i + NV] + v); }
  V operator[](int x) { return get(x, x + 1); }
};
vector<vector<long long>> mul_mod(vector<vector<long long>> A,
                                  vector<vector<long long>> B) {
  int H = A.size();
  int W = B[0].size();
  int K = A[0].size();
  vector<vector<long long>> C(H, vector<ll>(W, 0));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = 0; k < K; k++) {
        C[i][j] += A[i][k] * B[k][j];
        C[i][j] %= 1000000007;
      }
    }
  }
  return C;
}
vector<vector<long long>> pow_mod_matrix(vector<vector<long long>> A, ll p) {
  vector<vector<long long>> ret =
      vector<vector<long long>>(A.size(), vector<long long>(A.size(), 0));
  for (int i = 0; i < A.size(); i++) ret[i][i] = 1;
  while (p > 0) {
    if (p & 1) ret = mul_mod(ret, A);
    A = mul_mod(A, A);
    p >>= 1;
  }
  return ret;
}
int main() {
  ll N, M;
  cin >> N >> M;
  char S[N];
  for (long long int i = (0); i <= (N - 1); i++) {
    S[i] = '0';
  }
  for (long long int i = (0); i <= (M - 1); i++) {
    ll tp1, tp2;
    cin >> tp1 >> tp2;
    if (tp1 == 1 && tp2 == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (S[tp1 - 1] != '0' && S[tp1 - 1] != ('0' + tp2)) {
      cout << -1 << endl;
      return 0;
    } else {
      S[tp1 - 1] = ('0' + tp2);
    }
  }
  if (S[0] == '0') S[0] = '1';
  for (long long int i = (0); i <= (N - 1); i++) {
    cout << (char)S[i];
  }
  cout << endl;
  return 0;
}
