import sys
N, M = map(int, input().split(" "))
Field = [0 for i in range(N)]
count = 0
for i in range(M):
    a, b = map(int, input().split(" "))
    a -=1
    if Field[a] != 0:
        count+=1
    else:
        Field[a] = b

if Field[0] == 0 or count !=0:
    print(-1)
else:
    for i in Field:
        print(i, end="")
