#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,s,c;
  cin >> N >> M;
  int A[N] = {0};
  int C[N] = {0};
  bool flag = true;
  
  for(int i = 0; i < M; i++){
    cin >> s >> c;
    if(C[s-1] == 1 && A[s-1] != c){
      
      flag = false;
      break;
    }else{
      C[s-1] = 1;
      A[s-1] = c;
    }
  }
  int sum = 0;
  for(int i = 0; i < N; i++) cout << A[i] * pow(10, N-i-1) << endl;
  if(flag){
    for(int i = 0; i < N; i++){
      cout << A[i] * pow(10, N-i-1) << endl;
      sum += (A[i] * pow(10, N-i-1));
    }
  }else sum = -1;
  cout << pow(10, N-1) << endl;
  if(sum < pow(10, N-1)) sum = -1;
  cout << sum << endl;

}