Revert back to queue based O(n^3) impl. It indeed runs in cubic.