           :else
           (inc middle))))))
 
-(defn read-values [total]
-  (loop [reverse-index total
+(defn read-values [total-lines]
+  (loop [current-line total-lines
          vals []]
-    (if (== reverse-index 0)
+    (if (== current-line 0)
       vals
-      (recur (dec reverse-index)
-             (concat vals [(Integer/parseInt (read-line))])))))
+      (recur (dec current-line)
+             (cons (Integer/parseInt (read-line)) vals)))))
 
-
-(defn process-print [index marbles queries]
-  (printf "CASE# %d:%n" index)
+(defn process-print [test-case-index marbles queries]
+  (printf "CASE# %d:%n" test-case-index)
   (loop [queries queries]
     (let [query (first queries)
           position (binary-search query marbles)]

         end (-> (count items)
                 (dec))]
    (let [middle (-> (+ begin end)
                     (quot 2))
          items (vec items)]
      (if  (> begin end)
        -1
        (cond


(defn main []
  (loop [line (read-line)
         test-case-index 1]
    (let [[n q] (->> (str/split line #" ")
                     (map #(Integer/parseInt %)))
          marbles (-> (read-values n)
                      (sort)
                      (vec))
          queries (-> (read-values q)
                      (reverse))]
      (when (and (not= n 0) (not= q 0))
        (process-print test-case-index marbles queries)
        (recur (read-line) (inc test-case-index))))))

(main)
