#include <bits/stdc++.h>
using namespace std;
double PI = 3.141592653589793;
const double EPS = 1e-9;
const int N = 1e6 + 5;
const long long mod = 1e9 + 7;
const int oo = 1e9 + 9;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int n, m, k;
long long fastpower(long long a, long long p) {
  if (p == 0) return 1;
  long long res = fastpower(a, p / 2);
  if (p % 2 == 0)
    return (res * res) % mod;
  else
    return (((res * res) % mod) * a) % mod;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (k == 1 || k > n)
    printf("%lld", fastpower(m, n));
  else if (k == n)
    printf("%lld", fastpower(m, (n + 1) / 2));
  else if (k % 2 == 0)
    printf("%d", m);
  else
    printf("%d", m * m);
}
