#include <bits/stdc++.h>
using namespace std;
int pw(int a, int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long rep = pw(a, b / 2), M = 1e9 + 7;
  if (b % 2 == 0) return (rep * rep) % M;
  return (((rep * rep) % M) * a) % M;
}
int main() {
  int n, k, m;
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    cout << pw(m, n);
    return 0;
  }
  if (k == n) {
    cout << pw(m, (n + 1) / 2);
    return 0;
  }
  long long answer = m;
  if (k % 2 == 1) {
    answer += m * (m - 1);
  }
  cout << answer << endl;
}
