#include <bits/stdc++.h>
using namespace std;
const int MOD = (1e9) + 7;
int main() {
  int n, m, k, i;
  long long ans;
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    ans = 1;
    for (i = 1; i <= n; i++) ans = (ans * m) % MOD;
    cout << ans << endl;
    return 0;
  }
  if (k == n) {
    ans = 1;
    for (i = 1; i <= (n + 1) / 2; i++) ans = (ans * m) % MOD;
    cout << ans << endl;
    return 0;
  }
  if (k % 2 == 0)
    cout << m << endl;
  else
    cout << m * m << endl;
  return 0;
}
