#include <bits/stdc++.h>
const long long mod = 1000000007;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  if (k == 1) {
    long long sol = 1;
    for (int i = 1; i <= n; ++i) sol = (sol * m) % mod;
    printf("%d\n", (int)sol);
  } else if (k < n) {
    if (k % 2 == 1)
      printf("%d\n", m * m);
    else
      printf("%d\n", m);
  } else if (k == n) {
    long long sol = 1;
    for (int i = 1; 2 * i <= n + 1; ++i) sol = (sol * m) % mod;
    printf("%d\n", (int)sol);
  } else {
    long long sol = 1;
    for (int i = 1; i <= n; ++i) sol = (sol * m) % mod;
    printf("%d\n", (int)sol);
  }
  return 0;
}
