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

num = [0] * N

P = [list(map(int,input().split())) for i in range(M)]

for i in range(M + 1):
    if M == 0:
        num[0] = 1
        print("".join([str(n) for n in num]))
        break
    if i == M:
        if N != 1 and num[0] == 0:
            print(-1)
        else:
            print("".join([str(n) for n in num]))
    elif num[P[i][0] - 1] == 0 or num[P[i][0] - 1] == P[i][1]:
        num[P[i][0] - 1] = P[i][1]
    else:
        print(-1)
        break
