NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]
sc = []
for i in range(M):
    addList = list(map(int, input().split()))
    sc.append(addList)
a = 10**(N-1)
while a < 10**N:
    j = str(a)
    bingo = True
    for l in sc:
        if int(j[l[0]-1]) != l[1]:
            bingo = False
    if bingo:
        break
    else:
        a += 1
if a == 10**N and bingo == False:
    print(-1)
elif M == 0 and N!=1:
    print(10**(N-1))
elif M == 0 and N==1:
    print(0)
else:
    print(a)