Solution for matching 3 pairs of socks of each color.