#include <bits/stdc++.h>
using namespace std;
template <typename T>
void pr(const T& t) {
  cout << t << "\n";
}
template <typename T, typename U, typename... ARGS>
void pr(const T& t, const U& u, const ARGS&... args) {
  cout << t << " ";
  pr(u, args...);
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  long long n, m;
  cin >> n >> m;
  string x;
  for (long long i = 0; i < n; ++i) x += '.';
  bool flag = 1;
  while (m--) {
    long long s, c;
    cin >> s >> c;
    if (x[s - 1] == '.') {
      x[s - 1] = c + '0';
    } else {
      if (x[s - 1] != c + '0') flag = 0;
    }
  }
  if (!flag) {
    pr(-1);
    return 0;
  }
  for (long long i = 0; i < n; ++i)
    if (x[i] == '.') x[i] = '1';
  if (n != 1 and x[0] == '0') x = "-1";
  pr(x);
  return 0;
}
