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

sc = []
for i in range(M) :
    sc.append([int(i) for i in input().split()])

low = pow(10,N-1)
high = pow(10, N)

for i in range(low,high) :
    numstr = str(i)
    is_match = True
    for item in sc :
        s = item[0]
        c = item[1]
        # print(numstr,numstr[s-1],s,c)
        if (int(numstr[s-1]) != c) :
            is_match = False
            break
    
    if (is_match) :
        print(numstr)
        break

if (not is_match) :
    print(-1)