N, M = map(int, input().split())
SC = []

if M == 0:
    if N > 1:
        print(10 ** N)
        exit()
    else:
        print(0)
        exit()

for _ in range(M):
    SC.append(tuple(map(int, input().split())))

SC = set(SC)

mem = []
ans = ['0'] * N
ans[0] = '1'

for idx, sc in enumerate(SC):
    if sc[0] in mem:
        print(-1)
        exit()
    if sc[0] == 1 and sc[1] == 0:
        print(-1)
        exit()
    
    mem.append(sc[0])
    ans[sc[0] - 1] = str(sc[1])

print(int(''.join(ans)))