public void foo() {
    for (int n = 5; n < 6; n++) {
            int count = 0;
            for (Permutation p : new UniversalPermClass(n)) {
                boolean sorted = false;
                // System.out.println(p);
                ArrayList<String> sortings = new ArrayList<String>();
                KStackState s = new KStackState(2, p.elements);
                Queue<KStackState> q = new ArrayDeque<KStackState>();
                q.add(s);
                while (q.size() > 0) {
                    s = q.remove();
                    if (s.isSorted()) {
                        // System.out.println(p + "\n\n" + toPSTricks(s.operationSequence));
                        count++;
                        sorted = true;
                        break;
                        // sortings.add(s.operationSequence);
                    }
                    // System.out.println(s);
                    KStackState r = s.mu();
                    if (r != null) {
                        q.add(r);
                    }
                    r = s.tau();
                    if (r != null) {
                        q.add(r);
                    }
                    r = s.lambda();
                    if (r != null) {
                        q.add(r);
                    }
                    r = s.rho();
                    if (r != null) {
                        q.add(r);
                    }
                }
                if (!sorted) System.out.println(p + " " + p.inverse());
//            if (sortings.size() > 1) {
//                System.out.println(p);
//                System.out.println();
//                for (String ss : sortings) {
//                    System.out.println(ss);
//                    System.out.println();
//                    System.out.println(toPSTricks(ss));
//                }
//            }
            }
            System.out.println(n + " " + count);
        }

}