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