n,m=map(int,input().split())
# a,b,c=map(int,input().split())
# s=input()
# s,t=map(str,input().split())
ans=[0]*n
anss=""
for i in range(m):
  s,c=map(int,input().split())
  ans[s-1]=c
if ans[0]==0:
  print(-1)
else:
  for x in ans:
    anss+=str(x)
  print(anss)