n,m = map(int, input().split())

ans = [" "]*n
flag = 0

#print(ans)

for i in range(m):
    s, c = map(int, input().split())
    if (ans[s - 1] == " " or ans[s - 1] == c):
        ans[s - 1] = c
    else:
        flag = 1
        break


if (m == 0):
    print(0)

if (flag == 1 or ans[0] == 0):
    print(-1)
else:
    for i in range(n):
        if (ans[i] != " "):
            print(ans[i],end="")
        elif (i == 0):
            print(1,end="")
        else:
            print(0, end="")

    print()