#include <bits/stdc++.h>
using namespace std;
long long int fast_mod(long long int base, long long int exp) {
  long long int res = 1;
  while (exp > 0) {
    if (exp & 1) res = (res * base) % 1000000007;
    base = (base * base) % 1000000007;
    exp = exp >> 1;
  }
  return res;
}
vector<long long int> parent(1000000), diff(1000000);
long long int find(long long int a) {
  if (parent[a] == a)
    return a;
  else {
    long long int temp = parent[a];
    parent[a] = find(parent[a]);
    diff[a] ^= diff[temp];
    return parent[a];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int m, n, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << fast_mod(m, n) << "\n";
  else if (k == n)
    cout << fast_mod(m, (n + 1) / 2) << "\n";
  else if (k % 2)
    cout << fast_mod(m, 2) << "\n";
  else
    cout << m << "\n";
  return 0;
}
