N,M = map(int,input().split())
ans = [-1 for i in range(N)]
for i in range(M):
  s,c = map(int,input().split())
  if ans[s-1]!=-1 and ans[s-1]!=c:
    print(-1);exit()
  if s-1==0 and c==0:
    print(-1);exit()
  ans[s-1]=c

for i in range(N):
  if i==0:
    if ans[0]==-1:
      print(1,end="")
    else:
      print(ans[0],end="")
  else:
    if ans[i]==-1:
      print(0,end="")
    else:
      print(ans[i],end="")