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