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

#print(A)
def main():
    if N==1:
        for i in range(0,10**N):
            for j in range(M):
                if str(i)[s[j][0]-1]!=str(s[j][1]):
                    break
                if j==M-1:
                    return i
    else:
        for i in range(10**(N-1),10**N):
            for j in range(M):
                if str(i)[s[j][0]-1]!=str(s[j][1]):
                    break
                if j==M-1:
                    return i

print(main())
            
