#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, a, b;
  cin >> n;
  cin >> m;
  int ar[n];
  for (i = 0; i < n; i++) ar[i] = 0;
  for (int j = 1; j <= m; j++) {
    cin >> a >> b;
    ar[a - 1] = b;
  }
  if (n == m) {
    for (i = 0; i < n; i++) cout << ar[i];
    cout << endl;
  } else
    cout << "-1" << endl;
}
