#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v) {
  string s = "{";
  bool first = true;
  for (const auto& x : v) {
    if (!first) s += ", ";
    first = false;
    s += to_string(x);
  }
  return s + "}";
}
void debug_out() { cerr << '\n'; }
template <typename First, typename... Next>
void debug_out(First F, Next... N) {
  cerr << " " << to_string(F);
  debug_out(N...);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int n, m;
  cin >> n >> m;
  string s(n, '#');
  while (m--) {
    int i;
    char c;
    cin >> i >> c;
    i = n - i;
    if (s[i] != '#' and s[i] != c) return cout << -1, 0;
    if (i < 0 or i > n - 1) return cout << -1, 0;
    s[i] = c;
  }
  bool trail = true;
  bool ok = true;
  reverse(s.begin(), s.end());
  for (char& c : s) {
    if (c != '#') trail = false;
    if (c == '#' and !trail)
      c = '0';
    else if (trail)
      c = '1';
  }
  bool ok2 = false;
  for (int i = 1; i < n; i++) {
    if (s[i] != '0') ok2 = true;
  }
  if (ok2 and s[0] == '0')
    ok = false;
  else if (!ok2 and s.size() > 1)
    ok = false;
  if (!ok)
    cout << -1 << '\n';
  else
    cout << s << '\n';
  return 0;
}
