NM = input().split()
N = int(NM[0])
M = int(NM[1])

from collections import defaultdict
sc = defaultdict(lambda: -1)
flg = False
for i in range(M):
  scc = input().split()
  if sc[scc[0]] == -1:
    sc[scc[0]] = scc[1]
  else:
    if scc[0] == "1" and scc[1] == 0 and N != 1:
      flg = True
      break
    elif sc[scc[0]] != scc[1]:
      flg = True
      break
if not flg:
  string = ["0"]*N
  for key, value in sc.items():
    string[int(key)-1] = value
  string = "".join(string)
  if string == "0"*N:
    if N != 1:
      print("-1")
    else:
      print("0")
  else:
    string = ["0"]*N
    string[0] = "1"
    for key, value in sc.items():
      string[int(key)-1] = value
    string = "".join(string)
    print(string)

else:
  print("-1")
