#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
template <typename TypeInt>
string itob(const TypeInt v, int base) {
  static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string ret;
  static numeric_limits<TypeInt> t;
  TypeInt n = v;
  if (t.is_signed) {
    if (v < 0) n *= -1;
  }
  while (n >= base) {
    ret += table[n % base];
    n /= base;
  }
  ret += table[n];
  if (t.is_signed) {
    if (v < 0 && base == 10) ret += '-';
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
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;
}
int ctoi(char c) { return c - '0'; }
int gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int lcm(long long a, long long b) { return a * b / gcd(a, b); }
bool primecheck(long long n) {
  if (n < 2)
    return false;
  else {
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0) return false;
    }
    return true;
  }
}
string reverserange(string s, long long a, long long b) {
  reverse(s.begin() + a - 1, s.begin() + b);
  return s;
}
int main() {
  int n, m;
  cin >> n >> m;
  map<int, char> ma;
  vector<pair<int, char>> z(m);
  for (int i = 0; i < m; i++) {
    int a;
    char b;
    cin >> a >> b;
    z.at(i).first = a;
    z.at(i).second = b;
    if (ma.count(a) && ma.at(a) != b) {
      cout << -1 << endl;
      return 0;
    } else
      ma[a] = b;
    if (a == 1 && b == '0' && n != 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  string s = "";
  for (int i = 0; i < n; i++) {
    s += 'Z';
  }
  for (int i = 0; i < m; i++) {
    s.at(z.at(i).first - 1) = z.at(i).second;
  }
  for (int i = 1; i < n; i++) {
    if (s.at(i) == 'Z') s.at(i) = '0';
  }
  if (s.at(0) == 'Z') s.at(0) = '1';
  cout << s << endl;
}
