query: SELECT ?item ?ancestor ?ed ?page ?desc ?path WITH {
  SELECT ?item ?ancestor ?ed ?page
  {
      ?item p:P1343 ?pp. ?pp ps:P1343 wd:Q104788952. ?pp pq:P304 ?page.
     FILTER(xsd:integer(?page)>=440)
      ?item (wdt:P22|wdt:P25)+ ?ancestor .
      ?ancestor p:P39 ?as.
    {
     { 
      ?as ps:P39 ?pos; pq:P582 ?ed.
    FILTER(?pos IN (wd:Q18810062,wd:Q18810063))
     }
    UNION
     { 
      ?as ps:P39 ?pos; pq:P582 ?ed; pq:P642 ?of.
    FILTER(?pos IN (wd:Q12097,wd:Q116))
    FILTER(?of IN (wd:Q161885,wd:Q215530,wd:Q174193))
     }
    }
   }
  } AS %t2 WITH {
    SELECT (?item as ?item2) (MAX(?ed) as ?ed2) {
      INCLUDE %t2 .
    } GROUP BY ?item
  } AS %t3 WHERE {
    INCLUDE %t2 .
    INCLUDE %t3 .
    FILTER ((?item=?item2) && (?ed=?ed2))
    BIND(CONCAT("{","{numdescendants|",strafter(str(?item),"entity/"),"|-}","}") AS ?desc)
    BIND(CONCAT("{","{descent path text|",strafter(str(?ancestor),"entity/"),"|",strafter(str(?item),"entity/"),"}","}") AS ?path)
  }
  ORDER BY xsd:integer(?page)