#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v;
int main() {
  cin >> n >> m;
  v.resize(n, -1);
  for (int i = 0; i < m; ++i) {
    int d, k;
    cin >> d >> k;
    --d;
    if (v[d] != -1 && v[d] != k) {
      cout << -1 << endl;
      return 0;
    }
    v[d] = k;
  }
  for (int i = 0; i < n; ++i) {
    if (v[i] == -1) {
      v[i] = i == 0 ? 1 : 0;
    }
  }
  if (n != 1 && v[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int c : v) {
    cout << c;
  }
  cout << endl;
}
