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