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