n,m = map(int,input().split())
ans = list()
sc_list = [map(int,input().split()) for _ in range(m)]
for num in range(pow(10,n)):
    for s,c in sc_list:
        if int(num / pow(10,n-s)) % 10 != c:
            break
    else:
        print(num)
        break