#include <bits/stdc++.h>
using namespace std;
typedef struct d3point {
  long double x;
  long double y;
  long double z;
} d3point;
d3point make_d3point(long double arg1, long double arg2, long double arg3) {
  d3point *p = new d3point;
  p->x = arg1;
  p->y = arg2;
  p->z = arg3;
  return *p;
}
const double eps = 1e-15;
const int maxN = 1 * 100000 + 10, mod = (int)1e9 + 7;
int lengthM(int, int);
void dijkstraM(int);
void dfsM(int);
long long chooseM(int, int);
void primeM(int);
long long powerM(int, int);
long double distanceM(d3point, d3point);
int gcdM(int, int);
int m, n, k;
int main(void) {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  if (k == 1)
    cout << powerM(m, n);
  else if (k < n)
    if (k % 2 == 0)
      cout << m;
    else
      cout << m * m;
  else if (n < k)
    cout << powerM(m, n);
  else
    cout << powerM(m, (k + 1) / 2);
  return 0;
}
int lengthM(int n, int r) {
  int p = 0;
  while (n) {
    n /= r;
    ++p;
  }
  return p;
}
void dijkstraM(int i) {
  vector<pair<int, int> > v[maxN];
  int prev[maxN];
  int dis[maxN];
  int n;
  int q;
  set<pair<int, int> > st;
  dis[i] = 0;
  for (int j = 0; j < n; ++j) {
    if (i != j) dis[j] = INT_MAX;
    prev[j] = -1;
    st.insert(make_pair(dis[j], j));
  }
  while (!st.empty()) {
    q = st.begin()->second;
    st.erase(st.begin());
    for (int j = 0; j < (int)v[q].size(); ++j)
      if (dis[v[q][j].first] > dis[q] + v[q][j].second) {
        st.erase(make_pair(dis[v[q][j].first], v[q][j].first));
        dis[v[q][j].first] = dis[q] + v[q][j].second;
        prev[v[q][j].first] = q;
        st.insert(make_pair(dis[v[q][j].first], v[q][j].first));
      }
  }
}
void dfsM(int i) {
  bool mark[maxN] = {};
  vector<int> v[maxN];
  int prev[maxN];
  mark[i] = 1;
  for (int j = 0; j < (int)v[i].size(); ++j)
    if (!mark[v[i][j]]) {
      dfsM(v[i][j]);
      prev[v[i][j]] = i;
    }
}
long long chooseM(int arg1, int arg2) {
  long long tmp1 = 1, tmp2 = 1;
  if (arg2 > arg1 / 2) arg2 = arg1 - arg2;
  for (int i = 1; i <= arg2; ++i) {
    tmp1 = (tmp1 * i) % mod;
    tmp2 = (tmp2 * (arg1 - i + 1)) % mod;
  }
  return tmp2 * powerM((int)tmp1, mod - 2);
}
void primeM(int last) {
  bool isNotPrime[maxN] = {};
  int minPrime[maxN];
  vector<int> prime;
  for (int i = 2; i < last + 1; ++i)
    if (!isNotPrime[i]) {
      prime.push_back(i);
      for (int j = 2; j < last / i + 1; ++j) {
        isNotPrime[j * i] = 1;
        minPrime[i * j] = i;
      }
    }
}
long double distanceM(d3point d1, d3point d2) {
  return sqrt(pow(d1.x - d2.x, 2) + pow(d1.y - d2.y, 2) + pow(d1.z - d2.z, 2));
}
long long powerM(int arg1, int arg2) {
  if (arg2 == 0) return 1;
  long long pow = powerM(arg1, arg2 / 2);
  pow = (pow * pow) % mod;
  if (arg2 % 2 == 1) pow = (pow * arg1) % mod;
  return pow;
}
int gcdM(int arg1, int arg2) {
  if (arg1 < arg2) swap(arg1, arg2);
  while (0 < arg2) {
    arg1 -= (arg1 / arg2) * arg2;
    swap(arg1, arg2);
  }
  return arg1;
}
