#include <bits/stdc++.h>
const double PI = acos(-1.0);
template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;
int main() {
  ll n, m;
  string s = "";
  cin >> n >> m;
  for (int i = (0); i < (n); ++i) {
    s += 'x';
  }
  ll a;
  char c;
  for (int i = (0); i < (m); ++i) {
    cin >> a >> c;
    if (s[a - 1] == 'x' || s[a - 1] == c) {
      s[a - 1] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (n == 1 && s[0] == 'x') {
    cout << 0 << endl;
    return 0;
  }
  if (s[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (s[0] == 'x') {
    s[0] = '1';
  }
  for (int i = (0); i < (n - 1); ++i) {
    if (s[i + 1] == 'x') {
      s[i + 1] = '0';
    }
  }
  cout << s << endl;
  return 0;
}
