You have a grid with n rows and 3 columns.
Each cell is colored with one of three colors:
R (Red)
G (Green)
B (Blue)
You want to count the number of valid ways to color the grid such that:
1. Row Constraint (No Monochrome Row)
No row may have all three cells the same color.
That is, the following row patterns are forbidden:
R R R
G G G
B B B
Every row must have at least two different colors.
2. Column Constraint (No Monochrome Column)
No column may have all n cells the same color.
In other words, for each of the 3 columns:
The n cells in that column cannot all be R
Cannot all be G
Cannot all be B
Every column must have at least two different colors somewhere among its n entries.
Goal:
Compute the number of valid n×3 grids that satisfy both constraints.