#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int n, m, k;
long long ans;
int main() {
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    ans = 1;
    for (int i = 1; i <= n; ++i) ans = ans * m % MOD;
  } else if (k == n) {
    ans = 1;
    int t = (n + 1) / 2;
    for (int i = 1; i <= t; ++i) ans = ans * m % MOD;
  } else if (k & 1)
    ans = m * (m - 1) + m;
  else
    ans = m;
  cout << ans << endl;
  return 0;
}
