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