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

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

for x in range(10**N):
    if len(str(x)) == N:
        for o in order_list:
            if str(x)[o[0]-1] != str(o[1]):
                break
        else:
            print(x)
            exit()

print(-1)