n,m = map(int,input().split())
anslist=[1]+[0]*(n-1)
caplist=[]
for i in range(m):
    a,b=map(int,input().split())
    if not a in caplist:
        anslist[a-1]=(anslist[a-1])*0+b
        caplist.append(a)
    elif b!=anslist[a-1]:
        print(-1)
        break
else:
    if n==1 and (anslist==[1] or anslist==[0]):
      print(0)
    elif anslist[0]==0:
      print(-1)
    else:
      map=map(str,anslist)
      print(''.join(map))
