use strict;
use warnings;
my $l = <STDIN>;
chomp($l);
my @line = split(/ /,$l);
my $n = shift @line;
my $m = shift @line;
my @result = (-1,-1,-1);
for (my $i = 0; $i < $m; $i++) {
  my @line = split(/ /,<STDIN>);
  my $s = shift @line;
  my $c = shift @line;
  chomp($c);
  if($result[$s - 1] != -1 && $result[$s - 1] != $c) {
    print -1;
    exit;
  };
  $result[$s - 1] = $c;
}
if($result[0] == 0 || $result[0] == -1) {
    print -1;
    exit;
}
for (my $i = 0; $i < $n; $i++) {
  my $val = $result[$i];
  if($val < 0) {
  	$val = 0;
  }
  print $val;
}