N,M = map(int,input().split())

d = {}
total = 0
for i in range(M):
  s,c = map(int,input().split())
  if s in d and d[s] < c:
    continue
  else:
    d[s] = c 

for a,b in d.items():
  if N-a >= 0:
    total += b * 10**(N-a)    
    
if len(str(total)) != N:
  print(-1)
elif total <= 0:
  print(-1)
else:  
  print(total)