import sequtils, strutils, algorithm, math
proc scanf(fmt: cstring){.header: "<stdio.h>", varargs.}
proc scan(): int = scanf("%lld", addr result)
template newSeqWith(y, x: int, p: untyped): untyped = newSeqWith(y, newSeqWith(x, p))

let N, M = scan()

var ng = false
var ans = newSeqWith(N, 0)
ans[0] = 1
var chk = newSeqWith(N, false)

for i in 0..<M:
  var s, c = scan()
  s -= 1

  if chk[s] and (c != ans[s]):
    ng = true
    break

  chk[s] = true
  ans[s] = c

if ans[0] == 0: ng = true

if ng:
  echo("-1")
else:
  echo(ans.mapIt($it).join())