N, M=map(int, input().split())
ans=["1"]*M
tmp=[]
f=0
for i in range(M):
  s, c=map(input().split())
  if [s, c] in tmp or (s==1 and c==0):
    f=1
  tmp.append([s,c])
  ans[s-1]=str(c)

if f==1:
  print(-1)
else:
  print("".join(ans))
   