end up with one possible set as shown in Image 3. Each edge line style represents a cube. The upper subgraph lets one derive the left and the right face colors of the corresponding cube. E.g.: The solid arrow from Red to Green says that the first cube will have Red in the left face and Green at the Right. The dashed arrow from Blue to Red says that the second cube will have Blue in the left face and Red at the Right. The dotted arrow from White to Blue says that the third cube will have White in the left face and Blue at the Right. The dash-dotted arrow from Green to White says that the fourth cube will have Green in the left face and White at the Right. The lower subgraph lets one derive the front and the back face colors of the corresponding cube. E.g.: The solid arrow from White to Blue says that the first cube will have White in the front face and Blue at the Back. The dashed arrow from Green to White says that the second cube will have Green in the front face and White at the Back. The dotted arrow from Blue to Red says that the third cube will have Blue in the front face and Red at the Back. The dash-dotted arrow from Red to Green says that the fourth cube will have Red in the front face and Green at the Back. The third image shows the derived stack of cube which is the solution to the problem. It is important to note that: You can arbitrarily label the cubes as one such solution will render 23 more by swapping the positions of the cubes but not changing their configurations. The two directed subgraphs can represent front-to-back, and left-to-right interchangeably, i.e. one of them can represent front-to-back or left-to-right. This is because one such solution also render 3 more just by rotating. Adding the effect in 1., we generate 95 more solutions by providing only one. To put it into perspective, such four cubes can generate 243 × 3 = 41472 configurations. It is not important to take notice of the top and the bottom of the stack of cubes. Generalizations Given n cubes, with the faces of each cube coloured with one of n colours, determining if it's possible to stack the cubes so that