#include <bits/stdc++.h>
using namespace std;
void printArray(long long int arr[], long long int n) {
  for (long long int i = 0; i < n; i++) cout << arr[i] << ' ';
}
void printMp(map<long long int, long long int> m) {
  map<long long int, long long int>::iterator it;
  for (it = m.begin(); it != m.end(); it++)
    cout << it->first << ' ' << it->second << endl;
}
void printUmp(unordered_map<long long int, long long int> m) {
  unordered_map<long long int, long long int>::iterator it;
  for (it = m.begin(); it != m.end(); it++)
    cout << it->first << ' ' << it->second << endl;
}
void printSt(set<long long int> s) {
  set<long long int>::iterator it;
  for (it = s.begin(); it != s.end(); it++) cout << *it << ' ';
}
void printMst(multiset<long long int> s) {
  multiset<long long int>::iterator it;
  for (it = s.begin(); it != s.end(); it++) cout << *it << ' ';
}
void printVec(vector<long long int> v) {
  for (long long int i = 0; i < v.size(); i++) cout << v[i] << ' ';
}
void printVec2(vector<long long int> v[], long long int n) {
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < v[i].size(); j++) cout << v[i][j] << ' ';
    cout << endl;
  }
}
set<pair<long long int, long long int>> primeset;
void SieveOfEratosthenes(long long int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long int p = 2; p <= n; p++)
    if (prime[p]) primeset.insert(make_pair(p, 1));
}
long long int id[1000001], size[1000001];
long long int ans;
long long int root(long long int x) {
  while (id[x] != x) {
    id[x] = id[id[x]];
    x = id[x];
  }
  return x;
}
void Union(long long int x, long long int y) {
  long long int p = root(x);
  long long int q = root(y);
  if (size[p] > size[q]) {
    id[q] = id[p];
    size[p] += size[q];
  } else {
    id[p] = id[q];
    size[q] += size[p];
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n;
  cin >> n;
  long long int m;
  cin >> m;
  long long int k;
  cin >> k;
  long long int mod = 1000000007;
  for (long long int i = 1; i < n + 1; i++) {
    size[i] = 1;
    id[i] = i;
  }
  for (long long int i = 1; i < n - k + 2; i++) {
    long long int start = i;
    long long int end = i + k - 1;
    while (start <= end) {
      Union(start, end);
      start++;
      end--;
    }
  }
  long long int product = 1;
  for (long long int i = 1; i < n + 1; i++) {
    if (id[i] == i) {
      product = ((product % mod) * (m % mod)) % mod;
    }
  }
  cout << product;
  return 0;
}
