Permute lists of lists : <p>Given n arrays of random sizes, I need to permute them like this:</p>

<pre><code>[a1, a2, a3]
[b1, b2]
[c1, c2]

[a1, b1, c1]
[a1, b1, c2]
[a1, b2, c1]
[a1, b2, c2]
[a2, b1, c1]
[a2, b1, c2]
[a2, b2, c1]
[a2, b2, c2]
[a3, b1, c1]
[a3, b1, c2]
[a3, b2, c1]
[a3, b2, c2]
</code></pre>

<p><strong>The columns order matters, lines dont.</strong></p>

<p>What is good way to achieve this. If possible, using this method contract:</p>

<pre class="lang-java prettyprint-override"><code>&lt;T&gt; List&lt;List&lt;T&gt;&gt; permute(List&lt;T&gt;... lists)
</code></pre>
