Niuniu likes calculating sums. He has recently learnt how to calculate sums using various methods. Here is one of them:
Note that [x] is 1 when x is true and 0 when x is false.
Can you calculate the sum? The answer may be large, so please calculate the sum modulo a given number K.



