Why to take modulus with 1e+7


#1

We have to modulus in-order to avoid overflow, why exactly take modulus with 1e+7.


#2

10^9+7 is a prime number, this causes nice properties, it’s basically used in most questions here. Look up prime fields if you want to know more.