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

ans = ["x"]*N

for i in range(M):
    s,c = map(int, input().split())
    s -= 1
    if N != 1 and s == 0 and c == 0:
        print(-1)
        exit()
    if ans[s] == "x":
        ans[s] = str(c)
    else:
        if ans[s] != str(c):
            print(-1)
            exit()

if ans[0] == "x":
    ans[0] = "1"
for i in range(1,N):
    if ans[i] == "x":
        ans[i] = "0"

ans = "".join(ans)
print(ans)