<?php

list($n, $m) = explode(' ', trim(fgets(STDIN)));

$ans = array();
for ($i=1; $i <= $n; $i++) {
  $ans[$i] = '*';
}

for ($i=0; $i < $m; $i++) {
  list($s, $c) = explode(' ', trim(fgets(STDIN)));

  if ($ans[$s] == '*' || $ans[$s] == $c) {
    $ans[$s] = $c;
  } else {
    echo -1;
    exit;
  }
}

if ($ans[1] === '0') {
  echo -1;
  exit;
}

foreach ($ans as $k => $v) {
  if ($v === '*') {
    $ans[$k] = 0;
  }
}

if ($ans[1] == 0) {
  $ans[1] = 1;
}

echo implode('', $ans);
