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

S = [-1 for i in range(N)]

flag = True
for _ in range(M):
    s, c = map(int, input().split())
    if S[s - 1] == -1 or S[s - 1] == c:
        S[s - 1] = c
    else:
        flag = False
        break

f = True
for i in range(len(S)):
    if f:
        f = False
        if S[i] == -1:
            S[i] = 1
    else:
        f = False
        if S[i] == -1:
            S[i] = 0

if S[0] == 0:
    flag = False

if flag:
    for s in S:
        print(s, end="")
else:
    print(-1)
