#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
  return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  return (b < a) ? (a = b, 1) : 0;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll extgcd(ll a, ll b, ll &x, ll &y) {
  x = 1, y = 0;
  ll g = a;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= a / b * x;
  return g;
}
ll ADD(const ll &a, const ll &b, const ll mod = MOD) { return (a + b) % mod; }
ll SUB(const ll &a, const ll &b, const ll mod = MOD) {
  return (a - b + mod) % mod;
}
ll MUL(const ll &a, const ll &b, const ll mod = MOD) {
  return (1LL * a * b) % mod;
}
ll DIV(const ll &a, const ll &b, const ll mod = MOD) {
  ll x, y;
  extgcd(b, mod, x, y);
  return MUL(a, (x + mod) % mod, mod);
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vi res(n, -1);
  for (int _ = (int)(0); _ < (int)(m); ++_) {
    int s, c;
    cin >> s >> c;
    s--;
    if (res[s] >= 0 and res[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    res[s] = c;
  }
  if (res[0] == 0) {
    cout << -1 << endl;
  } else {
    for (auto &e : res) chmax(e, 0);
    chmax(res[0], 1);
    for (int i = (int)(0); i < (int)(n); ++i) {
      cout << res[i];
    }
    cout << endl;
  }
  return 0;
}
