#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll Max(ll(a), ll(b), ll(c)) { return max(max(a, b), c); }
ll Min(ll(a), ll(b), ll(c)) { return min(min(a, b), c); }
ll gcd(ll(a), ll(b)) {
  ll c = a;
  while (a % b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return b;
}
int main() {
  ll N, M;
  cin >> N >> M;
  string an = "";
  for (long long i = 0; i < (long long)(N); i++) {
    an += '?';
  }
  for (long long i = 0; i < (long long)(M); i++) {
    ll s;
    char c;
    cin >> s >> c;
    if (an.at(s - 1) == '?')
      an.at(s - 1) = c;
    else if (an.at(s - 1) == c)
      continue;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (an.at(0) == '?')
    an.at(0) = '1';
  else if (an.at(0) == '0') {
    cout << -1 << endl;
    return 0;
  }
  for (long long i = 0; i < (long long)(N - 1); i++) {
    if (an.at(i + 1) == '?') an.at(i + 1) = '0';
  }
  for (long long i = 0; i < (long long)(N); i++) cout << an.at(i);
  cout << endl;
}
