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 N != 1 and num[0] == 0:
  print(-1)
else:
  tmp = 0
  for i in range(N):
    tmp += num[i]*10**(N-1-i)
  print(tmp)