#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int p = 1000000007;
  long long int res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y >>= 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << power(m, n);
  else if (k == n)
    cout << power(m, (n + 1) / 2);
  else if (k % 2)
    cout << m * m;
  else
    cout << m;
}
