n,m=map(int,input().split())
if m==0 and n==1:
  print(0)
  exit()
else:
  print("1"+"0"*(n-1))
  exit()
  
x=["0" for _ in range(n)]
for _ in range(m):
  s,c=map(int,input().split())
  if x[s-1] != '0' and x[s-1] != str(c):
    print(-1)
    break
  else:
    x[s-1] = str(c)
else:
  if n==1:
    print(x[0])
  elif x[0]=='0':
    print(-1)
  else:
    print("".join(x))