In the problem statement it is given **than P/Q, where P and Q are coprime positive integers. You should compute P⋅Q−1 modulo 10^9+7,** where Q−1 denotes the multiplicative inverse of Q modulo 10^9+7.

But then how can for 1/5 the answer becomes 400000003.

multiplicative inverse of 5 modulo 10^9+7 is 400000003