N, M = map(int, input().split())
# N, M = 3, 3
ans = [0] * N
ans[0] = 1


for i in range(M):
    s, c = map(int, input().split())
    if ((s == 1) and (c == 0)):
        print(-1)
        exit()
    elif s == 1:
        ans[s - 1] = c
        continue
    if (ans[s - 1] == 0) or (ans[s - 1] == c):
        ans[s - 1] = c
    else:
        print(-1)
        exit()

ans = map(str, ans)
print("".join(ans))
