#include <bits/stdc++.h>
using namespace std;
long long int fastpow(long long int base, long long int exp, long long int M) {
  long long int res = 1;
  while (exp > 0) {
    if (exp & 1) res = (res * base) % M;
    base = (base * base) % M;
    exp >>= 1;
  }
  return res;
}
vector<long long int> par, sz, vis, dis;
vector<vector<long long int>> graph;
vector<vector<pair<long long int, long long int>>> wgraph;
void init(long long int n) {
  par.resize(n);
  sz.resize(n);
  wgraph.resize(n);
  dis.resize(n);
  vis.resize(n);
  graph.resize(n);
  for (long long int i = 0; i <= n - 1; ++i) {
    par[i] = i;
    sz[i] = 1;
    dis[i] = 1e18;
  }
}
long long int root(long long int a) {
  while (a != par[a]) {
    par[a] = par[par[a]];
    a = par[a];
  }
  return a;
}
void unio(long long int a, long long int b) {
  long long int r_a = root(a);
  long long int r_b = root(b);
  if (par[r_a] != r_b) {
    if (sz[r_a] < sz[r_b]) {
      par[r_a] = par[r_b];
      sz[r_b] += sz[r_a];
      sz[r_a] = 0;
    } else {
      par[r_b] = par[r_a];
      sz[r_a] += sz[r_b];
      sz[r_b] = 0;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v(n, -1);
  for (long long int i = 0; i <= m - 1; ++i) {
    long long int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0 && n > 1) {
      cout << -1;
      return 0;
    }
    if (v[s - 1] == -1 || v[s - 1] == c) {
      v[s - 1] = c;
    } else {
      cout << "-1";
      return 0;
    }
  }
  if (v[0] == -1) v[0] = 1;
  for (long long int i = 1; i <= n - 1; ++i) {
    if (v[i] == -1) {
      v[i] = 0;
    }
  }
  for (long long int i : v) cout << i;
  return 0;
}
