#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n, 0);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    vec[s - 1] = c;
  }
  if (n == 1) {
    cout << vec[0] << endl;
    return 0;
  }
  if (vec[0] == 0) {
    cout << -1 << endl;
  } else {
    cout << vec[0] * pow(10, n - 1) << endl;
  }
  return 0;
}
