#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
int mul(int a, int b) {
  long long pa = a;
  long long pb = b;
  return (int)((pa * pb) % MOD);
}
int powMOD(int x, int n) {
  int r = 1;
  while (n) {
    if (n & 0x01) r = mul(r, x);
    x = mul(x, x);
    n /= 2;
  }
  return r;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    cout << powMOD(m, n) << endl;
  } else if (k == n) {
    cout << powMOD(m, (n + 1) / 2) << endl;
  } else if (k & 0x01) {
    cout << (m * m) << endl;
  } else {
    cout << (m) << endl;
  }
  return 0;
}
