<?php
  fscanf(STDIN,"%d%d",$n, $m);
  $ans = str_repeat("0",$n);
  $kta=0;
  for($i=0; $i<$m; $i++){
      fscanf(STDIN,"%d%d",$s, $c);
      $ans[$s-1] = $c;
      $kta = max($kta,$s);
  }
  if($kta < 3 && $ans[$kta+1] == 0){
      echo "-1";
  }else{
      echo $ans;
  }