query: SELECT ?continent ?river ?continentLabel ?riverLabel
  WHERE
  {
    {
      SELECT ?continent (MAX(?length) AS ?length)
      WHERE
      {
        ?river wdt:P31/wdt:P279* wd:Q355304;
               wdt:P2043 ?length;
               wdt:P30 ?continent.
      }
      GROUP BY ?continent
    }
    ?river wdt:P31/wdt:P279* wd:Q355304;
           wdt:P2043 ?length;
           wdt:P30 ?continent.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  }
  ORDER BY ?continentLabel