#include <bits/stdc++.h>
using namespace std;
class DisjointSet {
 public:
  explicit DisjointSet(int n) {
    whichset_ = vector<int>(n);
    height_ = vector<int>(n, 1);
    for (int i = 0; i < n; ++i) whichset_[i] = i;
  }
  int Find(int node) {
    if (whichset_[node] == node) return node;
    return (whichset_[node] = Find(whichset_[node]));
  }
  void Merge(int first_node, int second_node) {
    int h1 = height_[Find(first_node)];
    int h2 = height_[Find(second_node)];
    if (h1 < h2) {
      whichset_[Find(first_node)] = Find(second_node);
      return;
    }
    whichset_[Find(second_node)] = Find(first_node);
    if (h2 < h1) return;
    ++height_[Find(second_node)];
  }

 private:
  vector<int> whichset_;
  vector<int> height_;
};
long long MODU = 1000000007LL;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  DisjointSet ds(n);
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (i + k <= n) {
      for (int(j) = 0; (j) < (k); ++(j)) ds.Merge(i + j, i + k - j - 1);
    }
  }
  set<int> s;
  for (int(i) = 0; (i) < (n); ++(i)) s.insert(ds.Find(i));
  long long ret = 1LL;
  for (int(i) = 0; (i) < (((int)(s).size())); ++(i)) {
    ret *= (long long)m;
    ret %= MODU;
  }
  cout << ret << endl;
}
