N, M = map(int, input().split())
P = [list(map(int, input().split()))for i in range(M)]

def check(num):
    ans = True
    for i in range(len(P)):
        #print(num[P[i][0] - 1], P[i][1])
        if int(num[P[i][0] - 1]) != P[i][1]:
            ans = False
    return ans
  
min_num = -1
for i in range(pow(10,N-1) ,pow(10,N)):
    if check(str(i)):
        min_num = i
        break
        
print(min_num)