#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
long long int me(long long int b, long long int p) {
  if (p == 0) {
    return 1;
  } else if (p % 2 == 0) {
    return me((b * b) % MOD, p / 2) % MOD;
  } else {
    return (b * (me((b * b) % MOD, (p - 1) / 2)) % MOD) % MOD;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    cout << me(m, n) << "\n";
  } else if (k == n) {
    cout << me(m, (n + 1) / 2) << "\n";
  } else if (k % 2 == 1) {
    cout << (m * m) % MOD << "\n";
  } else if (k % 2 == 0) {
    cout << m << "\n";
  }
  return 0;
}
