SP153 SCALES - Balancing the Stone
Description
You are given scales for weighing loads. On the left side lies a single stone of known weight W
Input Format
The input begins with the integer t, the number of test cases. Then t test cases follow.
For each test case, the first line contains three integers: N L D, where N denotes the number of weights at your disposal, L is the length of the binary representation of number W, and D is the modulus (1
Output Format
For each test case, output a single line containing one integer - the calculated number of possible weight placements, modulo D.