N,M = map(int,input().split())
lst = [0] * N
for i in range(M):
  s,c = map(int,input().split())
  lst[s-1] = c
idx = 10**9
if (lst[0] != 0):
  str_lst = list((map(str,lst)))
  print(''.join(str_lst))
else:
  print(-1)