N, M = list(map(int, input().split()))
num = [0]*N
for i in range(M):
  s, c = list(map(int, input().split()))
  num[s-1] = c
if num[0] == 0:
  print(-1)
else:
  print(num[0]*100 + num[1]*10 + num[2]*1)