#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1e9;
const long long mod = 1000000007;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long pow_kai(long long a, long long n) {
  long long x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a;
    }
    a = a * a;
    n >>= 1;
  }
  return x;
}
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  vector<char> res(n, '0');
  int s;
  char c;
  vector<int> S(m);
  for (int i = 0; i < (m); i++) {
    cin >> s >> c;
    res[s - 1] = c;
    S[i] = s;
  }
  if ((n > 1 && res[0] == '0') || n == 1 && m == 0) {
    cout << -1 << "\n";
    return 0;
  }
  string rr;
  for (int i = 0; i < (res.size()); i++) {
    rr += res[i];
  }
  cout << rr << "\n";
}
