function printAllCombination(arr) {
let pre = arr[0];
for (let i = 1; i < arr.length; i++) {
let temp = [];
pre.forEach((item) => {
arr[i].forEach((val) => {
temp.push(`${item}${val}`);
});
});
pre = temp;
}
return pre.join(",");
}
console.log(printAllCombination(input));