o = input().split()
ans = ""
r = ["e" for i in range(int(o[0]))]
for i in range(int(o[1])):
  p = input().split()
  if r[int(p[0])-1] != "e" and r[int(p[0])-1] != p[1]:
    ans = "-1"
    break
  r[int(p[0])-1] = p[1]

if r[0] == "0":
  ans = "-1"
else:
  res =  ""
  for i in range(len(r)):
    res = res + str(r[i])
  if res.replace("e", "0").lstrip("0") == "":
    ans = "0"
  elif res[0] == "e":
    temp = list(res)
    temp[0] = "1"
    ans = "".join(temp)


print(ans)