#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& a) {
  return os << "(" << a.first << "," << a.second << ")";
}
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << (*i) << " ";
  cout << endl;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
int nextInt() {
  int x;
  scanf("%d", &x);
  return x;
}
long long nextLong() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int main2() {
  int N = nextInt();
  int M = nextInt();
  bool ok = true;
  string ans(N, '?');
  for (int i = 0, _n = (int)(M); i < _n; ++i) {
    int s = nextInt() - 1;
    int c = nextInt();
    if (s >= N) {
      ok = false;
    } else if (ans[s] != '?' && ans[s] != c + '0') {
      ok = false;
    } else if (s == 0 && c == 0) {
      ok = false;
    } else {
      ans[s] = '0' + c;
    }
  }
  for (int i = 0, _n = (int)(N); i < _n; ++i) {
    if (ans[i] == '?') {
      ans[i] = i == 0 ? '1' : '0';
    }
  }
  if (ok)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
int main() {
  main2();
  return 0;
}
