#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int adj[2500][2500];
bool used[2500];
long long int expo(long long int a, long long int b, long long int m) {
  long long int y = a, x = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % m;
    }
    y = (y * y) % m;
    b = b / 2;
  }
  return x % m;
}
void DFS(int u) {
  used[u] = true;
  for (int i = 0; i < n; i++) {
    if (adj[u][i] == 0) continue;
    if (!used[i]) {
      DFS(i);
    }
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  memset(adj, 0, sizeof(adj));
  for (int i = 0; i < n - k + 1; i++) {
    for (int j = 0; j <= k / 2; j++) {
      adj[i + j][i + k - 1 - j] = 1;
      adj[i + k - 1 - j][i + j] = 1;
    }
  }
  memset(used, false, sizeof(used));
  int comp = 0;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      comp++;
      DFS(i);
    }
  }
  long long int res = expo(m, comp, 1000000007LL);
  cout << res;
  printf("\n");
  return 0;
}
