n, m = map(int, input().split())
ctr = [-1 for _ in range(n)]
flag = True
for i in range(m):
  p, q = map(int, input().split())
  p -= 1
  if ctr[p] == -1:
    ctr[p] = q
  else:
    flag = False
    break

flag = False if ctr[0] = 0

if flag:
  for i in ctr:
    print(1 if i == -1 else i, end="")
else:
  print(-1)