#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 23;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
void mul(int &a, int b) { a = a * 1LL * b % MOD; }
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, k;
  cin >> n >> m >> k;
  if (n < k || k == 1) {
    int ans = 1;
    for (int i = (0); i < (n); ++i) mul(ans, m);
    cout << ans << "\n";
    return 0;
  }
  if (n == k) {
    int ans = 1;
    for (int i = (0); i < ((n + 1) / 2); ++i) mul(ans, m);
    cout << ans << "\n";
    return 0;
  }
  if (k & 1) {
    cout << m * m << "\n";
    return 0;
  }
  cout << m << "\n";
}
