N,M=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(M)]
kouho=[]
count = 0
for i in range(10**(N-1),10**N+1):
    count=0
    if len(str(i))==N:
        for j in range(M):
            if str(i)[SC[j][0]-1]==str(SC[j][1]):
                count+=1
            if count==M:
                print(i)
                exit()
else:
    print("-1")