#include <bits/stdc++.h>
using namespace std;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T, class Y>
using P = pair<T, Y>;
template <class T, class Y>
ostream& operator<<(ostream& o, P<T, Y>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, V<T>& v) {
  for (T& t : v) o << t << ",";
  return o;
}
template <class T>
void uniq(V<T>& v) {
  sort(((v).begin()), ((v).end()));
  v.erase(unique(((v).begin()), ((v).end())), v.end());
}
template <class A, size_t N, class T>
void Fill(A (&a)[N], const T& v) {
  fill((T*)a, (T*)(a + N), v);
}
const int MOD = 1e9 + 7;
__int128_t gcd(__int128_t a, __int128_t b, __int128_t& x, __int128_t& y) {
  if (!b) {
    x = 1;
    y = 0;
    return a;
  }
  __int128_t d = gcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
long long modInv(long long a, long long m = MOD) {
  __int128_t x, y;
  gcd(a, m, x, y);
  return (x % m + m) % m;
}
long long modPow(__int128_t a, __int128_t n, long long m = MOD) {
  __int128_t p = 1;
  for (; n; n >>= 1, a = a * a % m)
    if (n & 1) p = p * a % m;
  return p;
}
const int IINF = 1e9 + 6;
const long long LINF = 1e18;
const int N = 1e4 + 1;
int n, m, d[3] = {-1, -1, -1};
void bad() {
  cout << -1 << endl;
  exit(0);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int _ = (0), _formax = (m); _ < _formax; _++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (d[s] >= 0 && c != d[s]) bad();
    d[s] = c;
  }
  if (d[0] == 0) bad();
  for (int i = (0), iformax = (n); i < iformax; i++) {
    if (d[i] < 0) d[i] = !i;
    cout << d[i];
  }
  cout << endl;
}
