N,M=map(int,input().split())
S=[list(map(str,input().split())) for _ in range(M)]
for i in range(10**(N-1),10**N):
    i=str(i)
    flag=True
    for t in range(M):
        if i[int(S[t][0])-1]==S[t][1]:
            continue
        else:
            flag=False
    if flag==True:
        print(i)
        break
    else:
        continue
if flag==False:
    print(-1)