5. Vasya is coming up with a 4-digit password for a code lock. He doesn't like the digit 2, so he doesn't use it. Additionally, he doesn't like when two identical digits are next to each other. He also wants the first digit to match the last digit. How many options need to be tried to guarantee guessing Vasya's password.
Answer: 504

Solution: The password must have the form ABCA, where A, B, C are different digits (not equal to 2). They can be chosen in $9 * 8 * 7=504$ ways.

Comment for graders: Half a point can be given to those who consider that the first digit cannot be zero.