o = input().split()
n = int(o[0])
m = int(o[1])
ans = ""
r = ["e" for i in range(n)]
for i in range(m):
  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":
  pass
else:
  for i in range(len(r)):
    res = res + str(r[i])
    ans = res
  if len(ans) != len(ans.strip("0")):
    ans = "-1"
  else:
    if res[0] == "e":
      res = res.lstrip("e")
      res = "1" + res
    ans = res.replace("e", "0")
print(ans)