<?php
$arr = explode(" ", trim(fgets(STDIN)));
$n = $arr[0];
$m = $arr[1];
$flg = true;

$no = array();
for($i = 0; $i < $n; $i++){
	$no[] = -1;
}

$sc = array();
for($i = 0; $i < $m; $i++){
	$sc = explode(" ", trim(fgets(STDIN)));
	$sc[0]--;
	if($sc[0] > $n){
		$flg = false;
		break;
	}elseif($sc[0] == 0 && $sc[1] == 0){
		$flg = false;
		break;
	}elseif($no[$sc[0]] == -1){
		$no[$sc[0]] = $sc[1];
	}elseif($no[$sc[0]] != $sc[1]){
		$flg = false;
		break;
	}
}
if($flg){
	for($i = 0; $i < $n; $i++){
		if($i == 0){
			if($no[$i] == -1){
				$no[$i] = 1;
			}
		}else{
			if($no[$i] == -1){
				$no[$i] = 0;
			}
		}
		echo $no[$i];
	}
}else{
	echo -1;
}
?>
