Efficient way needed

19 Views Asked by At

Given N, M find the :

GCD(1, 1) * GCD(1, 2) * … * GCD(1, M) * GCD(2, 1) * GCD(2, 2) * … * GCD(2, M) * … * GCD(N, 1) * GCD(N, 2) * … * GCD(N, M) modulo 10^9+7

Constraints:

1 <= N, M <= 2 * 10^7

Tried using brute force but need a help to improve.