<?php
$input = file_get_contents('php://stdin');
$inarr = explode("\n", $input);

$nmList = explode(" ", $inarr[0]);
$n = $nmList[0];
$m = $nmList[1];

var_dump(gettype($n));

$numList = array_map(function ($e) {
    return explode(" ", $e);
  }, array_splice($inarr, 1, $m));

$result = array_fill(0, $n, "999");

foreach($numList as $num){
    if($result[$num[0]-1]=="999"){
        $result[$num[0]-1]=$num[1];
    }
    else{
        if($result[$num[0]-1]!=$num[1]){
            echo "-1";
            exit();
        }
    }
}
if($n!="1" and $result[0]=="999"){
    $result[0]="1";
}
if(($n!="1" and $result[0]=="0")){
    echo "-1";
    exit();
}
foreach($result as &$num){
    if($num=="999"){
        $num="0";
    }
    echo $num;
}
?>