# C

N, M = map(int, input().split())

sc = {}

for _ in range(M):
  si, ci = map(int, input().split())
  if si not in sc.keys():
    sc[si] = [ci]
  else:
    sc[si] += [ci]

ans = -1

flag = True

for v in sc.values():
  if len(set(v))>1:
    flag = False

if 1 in sc.keys() and set(sc[1])=={0}:
  flag = False

if flag:
  cand = [0]*N
  cand[0] = 1
  for k, v in sc.items():
    cand[k-1] = v[0]
  ans = "".join([str(c) for c in cand])

print(ans)
