nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
nl = [None for i in range(n)]
result = ""
zf = 0

for i in range(m):
  temp = list(map(int, input().split()))
  keta = temp[0]
  c = temp[1]
  if keta == 1 and c == 0:
    zf = 1
  elif nl[keta-1] == None:
    nl[keta-1] = c
  else:
    if nl[keta-1] != c:
      zf = 1
if zf == 1:
  print("-1")
else:
  for i in range(len(nl)):
    if nl[i] == None:
      if i==0:
        nl[i]=1
      else:
        nl[i]=0
  nl = list(map(str, nl))
  length = 0
  while length != len(nl):
    result = result + nl[length]
    length += 1
  print(result)
  
  
