#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = ll(1e18) + 1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> v(n, -1);
  for (ll i = 0; i < (m); ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (v[s] == -1)
      v[s] = c;
    else {
      if (v[s] == c)
        continue;
      else {
        cout << -1;
        return 0;
      }
    }
  }
  for (ll i = 0; i < (n); ++i) {
    if (n >= 2 and i == 0) {
      if (v[i] == 0) cout << -1;
      return 0;
    }
    if (v[i] == -1) {
      if (i == 0 and n >= 2)
        v[i] = 1;
      else
        v[i] = 0;
    }
    cout << v[i];
  }
}
