#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const double eps = 1e-8;
const int mod = 1e9 + 7;
int n, m, k;
int quick(int m, int n) {
  int ans = 1;
  while (n) {
    if (n & 1) ans = (1ll * ans * m) % mod;
    n >>= 1;
    m = (1ll * m * m) % mod;
  }
  return ans;
}
int main() {
  while (cin >> n >> m >> k) {
    if (k > n || k == 1) {
      cout << quick(m, n) << endl;
    } else if (k == n) {
      cout << quick(m, (n + 1) >> 1) << endl;
    } else {
      if (k & 1) {
        cout << (m * 1ll * m) % mod << endl;
      } else {
        cout << m % mod << endl;
      }
    }
  }
  return 0;
}
