N, M = map(int, input().split())
ans = {}
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print(-1)
        exit()
    else:
        if s in ans.keys():
            if c != ans[s]:
                print(-1)
                exit()
        else:
            ans[s] = c
num = ["1"] + ["0"]*(N-1)
for k, v in ans.items():
    num[k-1] = str(v)
print("".join(num))
