#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int array[n];
  for (int i = 0; i < n; i++) {
    array[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int p, k;
    cin >> p >> k;
    array[p - 1] = k;
  }
  if (array[0] == 0 && n > 1) {
    cout << "-1\n";
  } else {
    for (int i = 0; i < n; i++) {
      cout << array[i];
    }
    cout << endl;
  }
  return 0;
}
