There are square pieces of paper, all of the same size. Each piece can be painted in one of different colors. These pieces are arranged to form a 3 \times 3 square. Your task is to determine how many unique squares can be created, taking into account that squares can be rotated. Since the result can be very large, you should provide the remainder when this number is divided by .
The input consists of two integers: and (1 \le K \le 1000, 2 \le P \le 2000000000).
The output should be a single integer representing the solution to the problem.
Example 1