from sys import exit

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

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

for i in range(10**(N-1),10**N):
    strnum = str(i)
    flag = True
    for j in Query:
        if strnum[j[0]-1] != str(j[1]):
            flag = False
            break
        else:
            None
    if flag:
        print(i)
        exit(0)

print('-1')