#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;
int main() {
  int n, m;
  cin >> n >> m;
  Vi v(3, -1);
  bool b = 1;
  for (int i = 0; i < (int)(m); i++) {
    int x, y;
    cin >> x >> y;
    x--;
    if (v[x] != -1 && v[x] != y)
      b = 0;
    else
      v[x] = y;
    if (x == 0 && y == 0) b = 0;
  }
  v[0] = max(v[0], 1);
  v[1] = max(v[1], 0);
  v[2] = max(v[2], 0);
  if (b)
    for (int i = 0; i < (int)(n); i++) cout << v[i];
  else
    cout << -1 << endl;
}
