#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long power(long long n, long long p) {
  long long val = 1;
  while (p > 0) {
    if (p % 2 == 0) {
      p /= 2;
      n *= n;
      n %= mod;
    } else {
      p--;
      val *= n;
      val %= mod;
    }
  }
  return val;
}
int main() {
  int n, m, f, g, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    cout << power(m, n);
    return 0;
  }
  if (k == n) {
    cout << power(m, (n + 1) / 2);
    return 0;
  }
  if (k % 2 == 0) {
    cout << m;
    return 0;
  }
  cout << m * m;
  return 0;
}
