N,M = map(int,input().split())

LIST=[10]*N
for i in range(M):
    s,c = map(int,input().split())
    if LIST[s-1]==10:
        LIST[s-1]=c
    else:
        print(-1)
        exit()

for i in range(N):
    if LIST[i]==10:
        LIST[i]=0

LIST2 = map(str, LIST) 
if N==1:
    print("".join(LIST2))
elif LIST[0]==0:
    print(-1)
else:
    print("".join(LIST2))


