import strutils
import sequtils

var nm = stdin.readLine.split(" ").map(parseInt)
var n = nm[0]
var m = nm[1]
var sc = newSeq[seq[int]](m)

var ans = newSeq[string](n)
var is_enable = true

for i in 0..<m:
  sc[i] = stdin.readLine.split(" ").map(parseInt)

# 存在しないのは
# s cが矛盾するとき
# s=Nかつc=0のとき

for digit in 0..<n:
  var is_digit = false
  for i in 0..<m:
    var s = sc[i][0] # 桁
    var c = sc[i][1] # 値
    if digit+1 == s:
      if is_digit and c.intToStr != ans[digit]:
        is_enable = false
      is_digit = true
      ans[digit] = c.intToStr
  if not is_digit:
    ans[digit] = "0"

# 指定がない場合
if m == 0:
  for digit in 1..<n:
    ans[digit] = "0"
  ans[0] = "1"

if ans[0] == "0" and n > 1:
  is_enable = false


if is_enable:
  echo join(ans)
else:
  echo "-1"
