N,M=map(int,input().split())
a=[]
for x in range(N):
  a.append(0)
for y in range(M):
  s,c=map(int,input().split())
  a[s-1]=c
ans=""
for z in range(N):
  ans += str(a[z])
ans = int(ans)
ans = str(ans)
if len(ans)==N:
  print(ans)
else:
  print(-1)