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