#include <iostream>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n] = {0};
  while (m--) {
  	int pos, num;
    cin >> pos >> num;
    a[n - pos] = min(num, a[n - pos]);  
  }
  if (a[0] == 0) {
    cout << -1;
  } else {
  	for (int ar : a) {
    	cout << ar;
    }
  }
  return 0;
}