           [(-> table
              (assoc-in [head (get w a)] tail)
              (assoc-in [tail (- (get w a))] head))
-           equiv]
+           equiv
+           head]
           
           (and (= a b) (not= head tail))
           (identify table equiv head tail)

        (fn [t s] (every? identity (for [[key row] s [gen val] row]
                                     (= val ((t key) gen)))))
        
        steps (traverse generator (partial contains? table))
        
        print-table
        (fn [t]
          (doseq [[key row] (sort t)]
            (println key row))
          (println))]

    (doseq [gen steps] (print-table (current gen)))
    (println "---")

          candidates (if (< n max-cosets) (conj matches n) matches)]
      (for [k* candidates]
        (let [t (-> table (assoc-in [k g] k*) (assoc-in [k* g*] k))]
          (scan-recursively rels t k))))))

(defn table-generator [nr-gens relators max-cosets]
  (let [gens (expand-generators nr-gens)
