N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]

duplicated = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None:
    duplicated = True
    break
  r[s-1] = c

v = -1
if not duplicated:
  for i in range(N):
    if r[i] is None:
      r[i] = 0
  v = sum(r[i] * 10**i for i in range(N))
  if v < 100:
    v = -1

print(v)
