N,M=list(map(int,input().split()));
SC=[list(map(int,input().split())) for i in range(M)]



for i in range(10**N):
  s=str(i)
  if(len(s)==N):
    
    OK=True
    for j in range(M):
      OK&=(s[SC[j][0]-1]==str(SC[j][1]))
      
    if(OK):
      print(s)
      exit()
      
print(-1)
    