#include using namespace std; #include using namespace atcoder; struct Eratosthenes { private: int _n; vector IsPrime; vector MinFactor; vector Mobius; public: Eratosthenes(int n = 1 << 20) : _n(n), IsPrime(n + 1, true), MinFactor(n + 1, -1), Mobius(n + 1, 1) { IsPrime[0] = IsPrime[1] = false; for (int p = 2; p <= n; p++) { if (!IsPrime[p]) continue; MinFactor[p] = p; Mobius[p] = -1; for (int q = 2 * p; q <= n; q += p) { IsPrime[q] = false; if (MinFactor[q] == -1) MinFactor[q] = p; if (q / p % p == 0) { Mobius[q] = 0; } else { Mobius[q] = -Mobius[q]; } } } } bool is_prime(int x) { return IsPrime[x]; } vector primes() { vector res; for (int i = 2; i <= _n; i++) { if (IsPrime[i]) res.push_back(i); } return res; } vector> factorize(int n) { assert(1 <= n && n <= _n); vector> res; if (n == 1) return res; while (n > 1) { auto p = MinFactor[n]; int ex = 0; while (MinFactor[n] == p) { ex++; n /= p; } res.emplace_back(p, ex); } return res; } vector divisors(int n) { assert(1 <= n && n <= _n); vector res = {1}; if (n == 1) return res; auto pf = factorize(n); for (auto [p, ex] : pf) { int sz = (int)res.size(); for (int i = 0; i < sz; i++) { int v = 1; for (int j = 0; j < ex; j++) { v *= p; res.push_back(res[i] * v); } } } return res; } vector get_mobius() { return Mobius; } }; long long modpow(long long a, long long n, int mod = 1000000007) { assert(mod != 0); if (mod == 1) return 0LL; a %= mod; long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } int main() { int A, B, N; cin >> A >> B >> N; const int MOD = 1e9 + 7; Eratosthenes E(B + 1); vector F(B + 1); for (int g = 1; g <= B; g++) { F[g] = modpow(B / g - (A - 1) / g, N, MOD - 1); } for (int p = 2; p <= B; p++) { if (!E.is_prime(p)) continue; for (int k = 1; k * p <= B; k++) { F[k] -= F[k * p]; F[k] += MOD - 1; if (F[k] >= MOD - 1) { F[k] -= MOD - 1; } } } long long ans = 1; for (int g = 1; g <= B; g++) { ans *= modpow(g, F[g], MOD); ans %= MOD; } cout << ans << endl; return 0; }