Hi i'm doing a simple translation program built from a a glossary and some statistic from a corpus.

Now i have realized that to get my program to work i need a algorithm that can get all the possible combinations from a N*M array.

EX:

[1(A1,A2,A3,......,An),2(B1,B2,B3,......,Bn),3(C1,C 2,C3,......,Cn),........N(N1,N2,N3,......,Nn)]

I haven't been able to solve this and would really need some help.