I am not understand what the sir want to explain and also not get how write for this problem.
-- $ Big gcd hint
We use gcd property to solve the problem: gcd(a,b)=gcd(a%b,b) or gcd(b%a,a).
After modulo is taken value become less than 10^7. After that represent number as the digit to powerof 10, and take modulo using modulo exponentiation.