#include <bits/stdc++.h>
using namespace std;
enum STATE { IN, OUT, BOUNDRY };
void fast_in_out() {
  std::ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
}
int dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
int dy[] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
int lx[] = {2, 2, -1, 1, -2, -2, -1, 1};
int ly[] = {-1, 1, 2, 2, 1, -1, -2, -2};
const long double eps = 1e-3;
const int N = 1e6 + 100, M = 5e2 + 50, mod = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long fast_power(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power & 1) {
      result = (result * base) % mod;
    }
    base = (base * base) % mod;
    power >>= 1;
  }
  return result;
}
int main() {
  fast_in_out();
  int n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << fast_power(m, n);
  else if (k == n)
    cout << fast_power(m, (n + 1) / 2);
  else if (k & 1)
    cout << m * m;
  else
    cout << m;
  return 0;
}
