So basically lots of guys have question Why “OUTPUT THE ANSWER MODULO 10^9 + 7"?
so the link of article will solve your doubt
please have look

https://www.hackerearth.com/practice/notes/abhinav92003/why-output-the-answer-modulo-109-7/