How to compute a unique set of squares where each side is one of 3 colors

In class we were given a problem to solve and implement in java, and I still cant wrap my head around it.

There is a set of 24 squares, where each side of every square has a border of either blue, red or green. Every possible permutation is allowed.

I’ve been trying to use for loops to output all possible permutations, but I always get it wrong – my total number is never 24.

Any help would be appreciated!