#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int64_t INF = (1LL << 60);
const long double inf = pow(10, 10);
const long double pi = acosl((long double)1);
const int64_t mod = 1000003;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
void solve() {
  int64_t n, m;
  cin >> n >> m;
  vector<int64_t> v(n, -1);
  for (int64_t i = 0; i < (int64_t)(m); i++) {
    int64_t s, c;
    cin >> s >> c;
    s--;
    if (v[s] != -1 && v[s] != c) {
      cout << -1 << endl;
      return;
    }
    v[s] = c;
  }
  if (v[0] == 0) {
    cout << -1 << endl;
    return;
  }
  for (int64_t i = 0; i < (int64_t)(n); i++) {
    if (v[i] == -1) {
      if (i == 0)
        v[i] = 1;
      else
        v[i] = 0;
    }
    cout << v[i];
  }
  cout << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  cout << setprecision(30);
  solve();
}
