The government plans a transport reform which will change ticket numbers. The new ticket numbers will consist of q digits in n-ary number system, where q is a prime number. Leading zeros are allowed.
A ticket is considered lucky if the product of all its digits added to the sum of all its digits, taken modulo n, equals s. Additionally, every lucky ticket has a degree of luckiness: the degree of luckiness of the ticket with digits a_1a_2…a_q equals (a_1+1)(a_2+2)…(a_q+q)+20a_1+21a_2+…+2q−1a_q.
For reform report, it is needed to calculate the sum of luckiness of all lucky tickets modulo q.
The first line contains three integers n, s and q (2≤n≤106, 0≤s<n, 2≤q≤106, q is prime).
Print the sum of luckiness of all lucky tickets modulo q.