Module C
  Sub Main(ByVal args() As String)
    dim arr() as string = split(console.readline())
    dim n,m,i,s as integer
    dim c as char
    n=arr(0):m=arr(1)
    dim dummy(n) as char
    for i=0 to n-1
      dummy(i)="0"c
    next
    for i=1 to m
      arr = split(console.readline())
      s=arr(0):c=arr(1)
      if dummy(s-1)="0"c then 
      	dummy(s-1)=c
      else if dummy(s-1)<>c then
        console.writeline("-1")
      	return
      end if
    next
    dim result as string = new string(dummy)
    console.writeline(if(dummy(0)="0"c,"-1",result))
  End Sub
End Module