See this topic.1. In how many ways can two squares be selected from an 8-by-8 chessboard so that they are not in the same row or the same column.
Put one ball of each color in each box and place the rest of the balls at random (i.e., in all possible ways).2. In how many ways can we place r red balls and w white balls in n boxes so that each box contains at least one ball of each colour.
Wikipedia page, (8).
In the future, please do not post bare questions. People would be more than willing to give you hints and show direction if you present your experience with the problem: what you have tried, what worked and what didn't, what exactly your difficulty is.