#include <bits/stdc++.h>
using namespace std;
struct $ {
  $() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(9);
  }
} $;
const int MOD = 1000000007LL;
template <typename T>
T mod_pow(T base, T exp, T mod = MOD) {
  if (exp == 0) {
    return 1;
  } else if (exp % 2 == 0) {
    T root = mod_pow(base, exp >> 1, mod);
    return (root * root) % MOD;
  } else {
    T prev = mod_pow(base, exp - 1, mod);
    return (prev * base) % MOD;
  }
}
int main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  if (k == 1) {
    cout << mod_pow(m, n) << endl;
  } else if (k == n) {
    cout << mod_pow(m, (n + 1) >> 1) << endl;
  } else if (k < n) {
    cout << m * mod_pow(m, k & 1) << endl;
  } else {
    cout << mod_pow(m, n) << endl;
  }
  return 0;
}
