#include <bits/stdc++.h>
using namespace std;
long long dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
long long dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
long long dx4[4] = {-1, 0, 1, 0};
long long dy4[4] = {0, -1, 0, 1};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long uni[100010];
long long root(long long a) {
  if (uni[a] < 0) return a;
  return uni[a] = root(uni[a]);
}
bool connect(long long a, long long b) {
  a = root(a);
  b = root(b);
  if (a == b) return false;
  if (uni[a] > uni[b]) {
    swap(a, b);
  }
  uni[a] = uni[a] + uni[a];
  uni[b] = a;
  return true;
}
signed main(void) {
  long long n, m;
  cin >> n >> m;
  vector<char> V(n, '.');
  for (long long i = 0; i < m; i++) {
    long long s;
    char c;
    cin >> s >> c;
    s--;
    if (V[s] == '.')
      V[s] = c;
    else {
      if (V[s] != c) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (n > 1 && V[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  string s = "";
  for (long long i = 0; i < n; i++) {
    if (i == 0 && V[0] == '.')
      s += '1';
    else {
      if (V[i] == '.')
        s += '0';
      else
        s += V[i];
    }
  }
  cout << s << endl;
}
