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