query: SELECT DISTINCT ?book ?commonsCategoryBook ?page ?command1
  WITH {
    SELECT ?book ?auth WHERE {
      ?book wdt:P195 wd:Q53764729 .
      ?book wdt:P50 ?auth .
    }
  } AS %pairs
  WITH {
    SELECT ?auth ?commonsCategoryAuth WHERE {
      hint:SubQuery hint:optimizer "None". # we have to disable the optimizer for this subquery because it gets confused by the ?commonsCategoryStatementEn part
      INCLUDE %pairs.
      OPTIONAL {
        ?auth wdt:P373 ?commonsCategoryStatement.
        BIND(STRLANG(CONCAT("Category:", ?commonsCategoryStatement), "en") AS ?commonsCategoryStatementEn)
        ?commonsCategoryFromStatement schema:name ?commonsCategoryStatementEn;
                                      schema:isPartOf <https://commons.wikimedia.org/>.
      }
      OPTIONAL {
        ?commonsCategoryFromSitelink schema:about ?auth;
                                     schema:isPartOf <https://commons.wikimedia.org/>.
        FILTER(STRSTARTS(STR(?commonsCategoryFromSitelink), "https://commons.wikimedia.org/wiki/Category:"))
      }
      BIND(COALESCE(?commonsCategoryFromStatement, ?commonsCategoryFromSitelink) AS ?commonsCategoryAuth)
      FILTER(BOUND(?commonsCategoryAuth))
    }
  } AS %authsWithCommonsCategories
  WITH {
    SELECT ?book ?commonsCategoryBook WHERE {
      hint:SubQuery hint:optimizer "None". # we have to disable the optimizer for this subquery because it gets confused by the ?commonsCategoryStatementEn part
      INCLUDE %pairs.
      OPTIONAL {
        ?book wdt:P373 ?commonsCategoryStatement.
        BIND(STRLANG(CONCAT("Category:", ?commonsCategoryStatement), "en") AS ?commonsCategoryStatementEn)
        ?commonsCategoryFromStatement schema:name ?commonsCategoryStatementEn;
                                      schema:isPartOf <https://commons.wikimedia.org/>.
      }
      OPTIONAL {
        ?commonsCategoryFromSitelink schema:about ?book;
                                     schema:isPartOf <https://commons.wikimedia.org/>.
        FILTER(STRSTARTS(STR(?commonsCategoryFromSitelink), "https://commons.wikimedia.org/wiki/Category:"))
      }
      BIND(COALESCE(?commonsCategoryFromStatement, ?commonsCategoryFromSitelink) AS ?commonsCategoryBook)
      FILTER(BOUND(?commonsCategoryBook))
    }
  } AS %booksWithCommonsCategories
  WHERE {
    INCLUDE %pairs
    INCLUDE %booksWithCommonsCategories.
    INCLUDE %authsWithCommonsCategories.
    MINUS {
      SERVICE <https://query.wikidata.org/bigdata/namespace/categories/sparql> {
        SERVICE gas:service {
          gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS";
                      gas:linkType mediawiki:isInCategory;
                      gas:traversalDirection "Reverse";
                      gas:in <https://commons.wikimedia.org/wiki/Category:CATEGORY_GOES_HERE>;
                      gas:out ?commonsCategoryBook.
        }
      }
    }
    BIND(REPLACE(wikibase:decodeUri(SUBSTR(STR(?commonsCategoryBook), STRLEN("https://commons.wikimedia.org/wiki/") + 1)), "_", " ") AS ?page)
    BIND(CONCAT('+', REPLACE(wikibase:decodeUri(SUBSTR(STR(?commonsCategoryAuth), STRLEN("https://commons.wikimedia.org/wiki/") + 1)), "_", " ")) AS ?command1)
  } ORDER BY ?page