#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
int bit(int x, int i) { return ((x >> (i - 1)) & 1); }
long long power(long long a, long long n, long long m) {
  long long ans = 1;
  while (n > 0) {
    if (n % 2) ans = (ans * a) % m;
    n = n >> 1;
    a = (a * a) % m;
  }
  return ans;
}
void merge(long long arr[], long long low, long long mid, long long high) {
  long long i = low, j = mid + 1, k = low;
  long long brr[100000];
  while (i <= mid && j <= high) {
    if (arr[i] <= arr[j])
      brr[k++] = arr[i++];
    else
      brr[k++] = arr[j++];
  }
  while (i <= mid) brr[k++] = arr[i++];
  while (j <= high) brr[k++] = arr[j++];
  for (k = low; k <= high; k++) arr[k] = brr[k];
}
void mergesort(long long arr[], long long low, long long high) {
  if (low < high) {
    long long mid = (low + high) / 2;
    mergesort(arr, low, mid);
    mergesort(arr, mid + 1, high);
    merge(arr, low, mid, high);
  }
}
bool cmp(pair<pair<long long, long long>, long long> a,
         pair<pair<long long, long long>, long long> b) {
  if (a.first.first == b.first.first) return a.first.second < b.first.second;
  return a.first.first < b.first.first;
}
int digit(int n) {
  int d = 0;
  while (n > 0) {
    d++;
    n = n / 10;
  }
  return d;
}
int mat[26][26];
void dfs(int node, vector<bool>& vis) {
  vis[node] = 1;
  for (int i = 0; i < 26; i++) {
    if (!vis[i] && mat[node][i]) dfs(i, vis);
  }
}
int root(int par[], int i) {
  if (par[i] != i) par[i] = root(par, par[i]);
  return par[i];
}
void make_union(int par[], int size[], int a, int b) {
  int ra = root(par, a);
  int rb = root(par, b);
  if (ra == rb) return;
  if (size[ra] < size[rb]) {
    par[ra] = par[rb];
    size[rb] += size[ra];
  } else {
    par[rb] = par[ra];
    size[ra] += size[rb];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  int par[n + 1], size[n + 1];
  for (int i = 0; i <= n; i++) {
    size[i] = 1;
    par[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    int x = i, y = i + k - 1;
    if (y > n) break;
    while (x < y) {
      make_union(par, size, x, y);
      x++;
      y--;
    }
  }
  set<int> S;
  for (int i = 1; i <= n; i++) S.insert(root(par, i));
  long long nn = S.size();
  long long x = m;
  long long ans = power(x, nn, mod);
  cout << ans % mod << "\n";
  return 0;
}
