import sys

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

num_list = list(range(10**(N-1), 10**N))

#print(num_list)
#print(SCs)

if(N == 1):
    num_list.append(0)

#print(num_list)

for num in num_list:
    num_hoge = list(str(num))
    num_hoge2 = list(map(int, num_hoge))

    cnt = 0
    for sc in SCs:
        if(num_hoge2[sc[0]-1] == sc[1]):
            cnt += 1
        
    if(cnt == len(SCs)):
        print(num)
        sys.exit()

print(-1)