#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (n > m) cout << "-1\n" << endl, exit(0);
  int pos, num, ar[m];
  memset(ar, 0, sizeof ar);
  bool ans = true;
  for (int i = 0; i < m; i++) {
    cin >> pos >> num;
    ar[pos - 1] = num;
  }
  if (ar[0] == 0) cout << "-1\n" << endl, exit(0);
  for (int i = 0; i < m; i++) {
    cout << ar[i];
  }
  cout << endl;
  return 0;
}
