#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const double pi = acos(-1);
const long long MODPRIMA = (long long)1e9 + 7;
const long long MAXX = (long long)1e18;
const long long MINN = -(long long)1e18;
const double EPS = 1e-9;
const int MAXN = 2000;
int N, M, K;
int parent[MAXN + 4];
bool sudah[MAXN + 4];
int power(int a, int b) {
  if (b == 0)
    return 1;
  else if (b == 1)
    return a % MODPRIMA;
  int tmp = power(a, b / 2);
  tmp = ((tmp % MODPRIMA) * (tmp % MODPRIMA)) % MODPRIMA;
  if (b % 2 == 0)
    return tmp;
  else
    return ((a % MODPRIMA) * tmp) % MODPRIMA;
}
int cari(int x) { return (parent[x] == x ? x : cari(parent[x])); }
void gabung(int x, int y) {
  int a = cari(x);
  int b = cari(y);
  parent[a] = b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M >> K;
  for (int i = 1; i <= N; i++) parent[i] = i;
  if (K > N)
    cout << power(M, N) << '\n';
  else {
    for (int i = 1; i <= N; i++) {
      if (K + i - 1 > N) break;
      int awal = i;
      int akhir = i + K - 1;
      while (awal < akhir) {
        gabung(awal, akhir);
        awal++;
        akhir--;
      }
    }
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
      if (!sudah[cari(i)]) {
        cnt++;
        sudah[cari(i)] = true;
      }
    }
    cout << power(M, cnt) << '\n';
  }
  return 0;
}
