using System.Collections.Generic;
public static void Main()
var a = new[] { "a", "b" };
var b = new[] { "1", "2", "3" };
List<bool[]> bools = new List<bool[]>();
for(int i = 0; i < Math.Pow(2, a.Length + b.Length); i++)
if(bits.Sum() == a.Length)
bools.Add(bits.Take(a.Length + b.Length).Select(x => x == 1).ToArray());
string[] result = new string[a.Length + b.Length];
for(int i = 0; i < result.Length; i++)
Console.WriteLine(string.Join(" ", result));
private static int[] GetBits(int num)
int[] result = new int[32];
for(int i = 0; i < result.Length; i++)
if( ((1 << i) & num) > 0)