N,M = map(int,input().split())
 
sclist = []
for count in range(M):
    d = list(map(int,input().split()))
    sclist.append(d)
 
flag = False;
for count in range(10**(N-1),10**(N)):
    flag = False
    for count1 in range(M):
        s = sclist[count1][0]
        c = sclist[count1][1]
        if str(count)[s-1] == str(c):
            flag = True
        else:
            flag = False
            break
    if flag == True:
        print(count)
        break
 
if flag == False and M != 0:
    print(-1)
elif flag == False and M == 0:
    if N == 1:
        print(0)
    else:
        prin(10**(N-1))
