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