#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int mpow(long long a, int p) {
  long long res = 1;
  for (; p > 0; p >>= 1) {
    if (p & 1) {
      res = res * a % mod;
    }
    a = a * a % mod;
  }
  return res;
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  if (k > n || k == 1) {
    cout << mpow(m, n);
  } else if (k == n) {
    cout << mpow(m, (n + 1) / 2);
  } else if (k % 2 == 0) {
    cout << m;
  } else {
    cout << m * m;
  }
  return 0;
}
