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

ans = [-1] * N

for i in range(M):
    s,c = map(int,input().split())
    if ans[s-1] != -1 and ans[s-1] != c :
        print(-1)
        exit()
    t[s-1] = c

if N != 1 :
    if ans[0] == 0 :
        print(-1)
        exit()
    if ans[0] == -1 :
        ans[0] = 1
    for i in range(N):
        if ans[i] == -1:
            ans[i] = 0
else :
    if ans[0] == -1 :
        ans[0] = 0

print(*ans,sep='')
