N, M = map(int, input().split())
if N < M:
  print(-1)
  exit()
SC = [list(map(int, input().split())) for _ in range(M)]
# remove duplicate num
SC = list(map(list, set(map(tuple, SC))))
num = ['0'] * N
pre = 0
for sc in SC:
  if sc[0] == 1 and sc[1] == 0 and M == 1 and N == 1:
    print(0)
    exit()
  elif sc[0] == 1 and sc[1] == 0 and M == 1:
    print(-1)
    exit()
  # duplicate s
  if sc[0] == pre:
    print(-1)
    exit()
  num[sc[0] - 1] = str(sc[1])
  pre = sc[0]
if num[0] == '0':
  num[0] = '1'
integer = "".join(num)
print(integer)