#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s, c;
  cin >> n >> m;
  vector<int> v(n);
  while (m--) {
    cin >> s >> c;
    v[s - 1] = c;
  }
  if (n > 1 && v[0] == 0)
    cout << -1 << "\n";
  else {
    for (int i : v) cout << i;
  }
  return 0;
}
