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)

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

    if (not is_match) :
        print(-1)
