<?php
fscanf(STDIN, "%d %d", $N, $M);
$arr = array();
for ($m=0; $m<$M; $m++){
    fscanf(STDIN, "%d %d", $s, $c);
    $arr[] = array($s, $c);
}

$isIncluded = FALSE;
for ($n=0;$n<1000;$n++){
    if (strlen(strval($n)) == $N){
        foreach ($arr as $item){
            if (strval($n)[$item[0]-1] == $item[1]){
                $isIncluded = TRUE;
                /*echo strval($n) . "\t" . $item[0] . "\t" . $item[1];
                echo "\n";*/
            } else {
                $isIncluded = FALSE;
                break;
            }
        }
        if ($isIncluded){
            //echo "Yes\n";
            echo $n;
            die();
        }
    }
}