N, M = map(int, input().split())
num = ["0" for y in range(N)]


for x in range(M):
    s, c = map(int, input().split())
    if s+1 > len(num):
        print(-1)
        exit()
    num[s-1] = str(c)

print("".join(num) if num[0] != "0" else -1)



