n,m=map(int,input().split())
keep=0
aa=["#"]*n
for i in range(m):
  s,c=map(str,input().split())
  s=int(s)
  if aa[s-1]=="#":
    aa[s-1]=c
  elif aa[s-1] !=c:
    keep=1
    print(-1)
    break
if keep==0:
  moji=""
  if aa[0]=="#":
    moji+="1"
  else:
    moji+=aa[0]
  for i in range(1,n):
    if aa[i]=="#":
      moji+="0"
    else:
      moji+=aa[i]
  print(moji)