#include <bits/stdc++.h>
using namespace std;
template <typename T>
const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-11;
int max(int a, int b, int c) { return max(a, max(b, c)); }
int min(int a, int b, int c) { return min(a, min(b, c)); }
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x < y ? x : y; }
long long max(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
long long min(long long a, long long b, long long c) {
  return min(a, min(b, c));
}
int main() {
  int n, m;
  cin >> n >> m;
  string s = "";
  for (int i = 0; i < (int)n; i++) {
    s += "X";
  }
  bool flg = true;
  for (int i = 0; i < (int)m; i++) {
    int si;
    char ci;
    cin >> si >> ci;
    si -= 1;
    if (s[si] != 'X' && s[si] != ci) {
      flg = false;
    }
    s[si] = ci;
  }
  if (s[0] == 'X') {
    s[0] = '1';
  }
  for (int i = 1; i < (int)n; i++) {
    if (s[i] == 'X') {
      s[i] = '0';
    }
  }
  if (s[0] == '0' || !flg) {
    cout << -1 << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}
