#include <bits/stdc++.h>
using namespace std;
long long Power(int base, int power) {
  if (power == 0) return 1ll;
  if (power == 1) return base % 1000000007;
  long long sub = Power(base, power / 2) % 1000000007;
  sub = (sub * sub) % 1000000007;
  if (power & 1) return (base * sub) % 1000000007;
  return sub;
}
int main() {
  long long n, m, k, res;
  while (cin >> n >> m >> k) {
    if (k == 1 || k > n) {
      cout << Power(m, n) << endl;
      continue;
    }
    if (k == n) {
      if (k & 1)
        cout << Power(m, 1 + (n / 2)) << endl;
      else
        cout << Power(m, n / 2) << endl;
      continue;
    }
    res = m;
    if (k & 1) {
      res += m * (m - 1);
    }
    cout << res << endl;
  }
}
