{"problem":{"name":"Nowhere P","description":{"content":"You are given a prime number $P$ not less than $2$, which you don't like. Let's call an array of integers $A_1, A_2, \\dots, A_N$ **very good** if it satisfies the following condition: *   there is no","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"jsc2021_d"},"statements":[{"statement_type":"Markdown","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)$.\n\n## Constraints\n\n*   $N$ and $P$ are integers.\n*   $1 ≤ N ≤ 10^9$\n*   $2 ≤ P ≤ 10^9$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $P$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"jsc2021_d","tags":[],"sample_group":[["3 3","2\n\nTwo arrays, $(1, 1, 2)$ and $(2, 2, 1)$, satisfy the condition."],["3 2","0"],["45108 2571593","224219544"]],"created_at":"2026-03-03 11:01:14"}}