Python some special products of a given list
<p>I would like to find a way for the possible products of the given list. Below, I have an example </p>

<p>So far, I tried this :</p>

<pre><code>for p in itertools.product(the_list, repeat=2):
        print p
</code></pre>

<p>But, this returns all the possibilities that can be generated from the given list. Can you please help me to generate the following example ?  </p>

<p>An example: </p>

<pre><code>the_list=['A1','A2','A3','B1','B2','B3','C1','C2','C3','D1','D2','D3']
The results should be: 
['A1A2','A1B2','A1C2','A1D2','A2A3','A2B3','A2C3','A2D3','A3A1','A3B1','A3C1','A3D1'
 'B1A2,'B2A3'...
 'C1A2'...']
</code></pre>

<p>Basically, the Capital letters refer the state and the numbers refer the sequence. So, if it starts with A1, it can only continue with a state with the number 2, for example first A1, then A2 or B2 or C2 or D2. It is also circular which means A3 is followed either by A1,B1,C1 or D1.</p>
