my ($N, $M) = glob<>;
%foo;
for($i=0;$i<$M;$i++){
    ($s,$c) = glob<>;
    if( ($s == 1 && $c == 0) || grep{$_ == $s && $foo{$_} != $c}keys(%foo)){
        print "-1";
        goto end;
    }
    $foo{$s} = $c;
}
$r = 0;
for($j=0;$j<$N;$j++){
    $f = $foo{$j+1};
    if($r == 0){
        $r = $f ? 1 : 0;
        print $f ? $f : "";
    }else{
        print $f ? $f : 0;
    }
}
end:{

}