RAINBOWB - Editorial

qstn:-http://www.codechef.com/SEPT14/problems/RAINBOWB

soltn:-http://www.codechef.com/viewsolution/4823960

I have seen the tutorial also and my solution is also same as described in tutorial bt i am getting WA may be because of modular problem.if that is the case plz explain how to overcome that hurdle and if not please point the mistake…

Thank you for help

//