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

l = []
total = 0
for i in range(M):
  s,c = map(int,input().split())
  if (s,c) not in l:
    l.append((s,c))
    total += c * 10**(N-s)

if len(str(total)) != N:
  print(-1)
else:
  print(total)  