N, M = list(map(int, input().split()))
sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))
    
for i in range(1000):
    if len(str(i)) == N:
        for j in range(M):
            s = sc[j][0]
            c = sc[j][1]
            if str(i)[s-1] != str(c):
                break
        else:
            print(i)
            break
        
            
                