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) || ($s == 1 && $c ==0) ) {
    print -1;
    exit;
  };
  $result[$s - 1] = $c;
}
if($n == 1 && ($result[0] == 0 || $result[0] == -1)) {
  print 0;
  exit;
}
for (my $i = 0; $i < $n; $i++) {
  my $val = $result[$i];
  if($val < 0) {
    if($i == 0){
  	  $val = 1;
    } else {
  	  $val = 0;
    }
  }
  print $val;
}