#include <bits/stdc++.h>
using namespace std;
long long int por(long long int x, long long int y) {
  long long int ans = 1, b = x;
  while (y) {
    if (y & 1) ans = (ans * b) % 1000000007;
    b = (b * b) % 1000000007;
    y >>= 1;
  }
  return ans;
}
int main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << por(m, n);
  else if (m == 1)
    cout << 1;
  else if (n == k)
    cout << por(m, (n + 1) / 2);
  else if (k % 2 == 0)
    cout << m;
  else
    cout << m * m;
  return 0;
}
