On working solution to sherlock_and_queries.

Failed to pass tests because of time out.