Medium Math > Modular Arithmetic

After being very successful event over a century , now BPL is very popular not only within the earth but also all over the universe. BCB planning to arrange it as an international event where there will be team from every planet. So its gonna be a very big event and Mr. Papon (President of BCB) is curious to know if they allow **N** teams how many matches they’re gonna need to arrange only for very 1st round? As you’re a famous programmer Mr. Papon needs your help. As you know , in BLP each team play with every other team exactly **K** times. (do not play with itself) And as answer is gonna be very big you have to print answer modulo **M**. Input: ------ 3 Integer N,K,M [separated by space] in a line for every test cases. Input will terminated by EOF. Output: ------- Print Case X: Y in a line for each test cases. Where X is case number and Y is answer. **Constrain :** **1 < N,M < 2^64, 1 <= K < 2^64** . there will be **at most 27005 test cases**. Sample Input : -------------- 8 2 1000 8 2 50 100 100 99 100 100 97 100 100 1000000000 7 2 100 Sample Output: -------------- Case 1: 56 Case 2: 6 Case 3: 0 Case 4: 9 Case 5: 495000 Case 6: 42

Md. Tariqul Islam