#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> num(n, -1);
  vector<bool> ketacheck(n, false);
  for (int i = 0; i < m; i++) {
    int st, ct;
    cin >> st >> ct;
    if (num[st - 1] != -1 and num[st - 1] != ct ||
        st == 1 and ct == 0 and n > 1) {
      cout << -1 << endl;
      return 0;
    } else {
      num[st - 1] = ct;
    }
  }
  for (int i = 0; i < n; i++) {
    if (num[i] == -1) {
      if (i == 0 && n > 1)
        num[i] = 1;
      else
        num[i] = 0;
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << num[i];
  }
  cout << endl;
  return 0;
}
