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]
res = ""
if ans != "-1":
  if r[0] == "e":
    r[0] = "1"
  for i in range(len(r)):
    res = res + str(r[i])
  ans = res.replace("e", "0")
  if len(ans) != len(ans.lstrip("0")):
    ans = "-1"
print(ans)