{"raw_statement":[{"iden":"problem statement","content":"You are given a prime number $P$ not less than $2$, which you don't like.\nLet's call an array of integers $A_1, A_2, \\dots, A_N$ **very good** if it satisfies the following condition:\n\n*   there is no $i$ with $1 \\le i \\le N$ and $A_1 + A_2 + \\dots + A_i \\equiv 0 \\bmod P$.\n\nConsider all $(P-1)^N$ arrays of length $N$ with elements from $1$ to $P-1$. How many of them are **very good**?\nAs this number can be very big, output it modulo $(10^9 + 7)$."},{"iden":"constraints","content":"*   $N$ and $P$ are integers.\n*   $1 ≤ N ≤ 10^9$\n*   $2 ≤ P ≤ 10^9$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $P$"},{"iden":"sample input 1","content":"3 3"},{"iden":"sample output 1","content":"2\n\nTwo arrays, $(1, 1, 2)$ and $(2, 2, 1)$, satisfy the condition."},{"iden":"sample input 2","content":"3 2"},{"iden":"sample output 2","content":"0"},{"iden":"sample input 3","content":"45108 2571593"},{"iden":"sample output 3","content":"224219544"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}