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