function doExchange(arr,depth){
for(var i=0; i<arr[depth].length; i++){
result[depth] = arr[depth][i]
if(depth != arr.length-1) {
doExchange(arr,depth+1)
} else {
results.push(result.join(','))
}
}
}
function test(arr) {
results =[]
result =[]
doExchange(arr, 0);
}