N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
guess=["0"]*N
for i in sc:
  guess[i[0]-1]=i[1]
if guess[0]==0:
  print("-1")
else:
  for i in guess:
    print(i,end="")
