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

while int(ans)!=int("9"*(N))+1:
  f=1
  for i in range(M):
    s,c=SC[i][0],SC[i][1]
    if ans[s]!=str(c):
      f=0
      break
  if f==0:
    ans= str(int(ans)+1)
  else:
    print(ans);exit()
print(-1)