# coding: utf-8
N, M = map(int, input().split())
d = {}
S = ["0" for _ in range(N)]
for _ in range(M):
    s, c = map(str, input().split())
    if s not in d.keys():
        d[s] = c
    else:
        if d[s] != c:
            print(-1)
            exit()
if N == 1:
    ans = "".join(S)
    print(ans)
    exit()
elif S[0] == "0" and "1" not in d.keys():
    S[0] = "1"
ans = "".join(S)
print(ans)