N,M = map(int, input().split())
candid=[-1]
temp=[]
for _ in range(M):
    A=list(map(int,input().split()))
    temp.append(A)

number=[0]*M
for i in range(N):
    number[temp[i][0]-1]=temp[i][1]

if number[0]==0:
    print(-1)
else:
    print("".join([str(i) for i in number]))