#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}
ll nCr(ll n, ll r) {
  ll ans = 1;
  for (int i = n; i > n - r; --i) {
    ans = ans * i;
  }
  for (int i = 1; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}
int main() {
  ll N, M;
  cin >> N >> M;
  if (N = 1 && M == 0) {
    cout << 0 << endl;
    return 0;
  }
  map<ll, ll> m;
  string S = "1";
  for (int i = 0; i < (int)(N - 1); i++) {
    S += '0';
  }
  for (int i = 0; i < (int)(M); i++) {
    ll a;
    char b;
    cin >> a >> b;
    m[a]++;
    if (m[a] > 1 && S.at(a - 1) != b) {
      cout << -1 << endl;
      return 0;
    }
    S.at(a - 1) = b;
  }
  if (S == "0") {
    cout << S << endl;
  } else if (S.at(0) == '0') {
    cout << -1 << endl;
  } else {
    cout << S << endl;
  }
}
