#include <bits/stdc++.h>
using namespace std;
long long inv(long long a, long long b) {
  return (a > 1 ? b - inv(b % a, a) * b / a : 1);
}
const long double e = 2.71828182845904523536028747;
const long double PI = 3.14159265359;
const long long inf = (1LL << 62);
const int iinf = (1 << 30);
const int mod = 1e9 + 7;
int n, m, k;
int lgput(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (1LL * ans * x) % mod;
    x = (1LL * x * x) % mod;
    y >>= 1;
  }
  return ans;
}
int main() {
  cin >> n >> m >> k;
  if (k > n || k == 1) return cout << lgput(m, n), 0;
  if (k == n) return cout << lgput(m, (n + 1) / 2), 0;
  if (k & 1) return cout << m * m, 0;
  return cout << m, 0;
  return 0;
}
