n,m = list(map(int, input().split()))
s = []
c = []
for _ in range(m):
    inputs = list(map(int, input().split()))
    s.append(inputs[0])
    c.append(inputs[1])

if n == 1:
    for i in range(10):
        istr = str(i)
        flag = True #このTrueは毎回新しくTrueになる
        for j in range(m):
            if not istr[s[j]-1] == str(c[j]):
                flag = False
            if flag == True:
                print(i)
                break
else: # n!=1
    for i in range(10**(n-1),10**n):
        istr = str(i)
        flag = True
        for j in range(m):
            if not istr[s[j]-1] == str(c[j]):
                flag = False
            else: #あっていた場合何もしない
                pass
        if flag:
            print(i)
            break