#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long bigMod(long long x, long long y, long long m) {
  if (y == 0) return 1 % m;
  if (y % 2 == 0) {
    long long temp = bigMod(x, y / 2, m);
    return (temp * temp) % m;
  }
  return (x % m * bigMod(x, y - 1, m)) % m;
}
int main() {
  ios::sync_with_stdio(false);
  long long n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    cout << bigMod(m, n, mod) << endl;
    return 0;
  }
  if (n == k) {
    cout << bigMod(m, (n + 1) / 2, mod) << endl;
    return 0;
  }
  if (k & 1)
    cout << bigMod(m, 2, mod) << endl;
  else
    cout << m << endl;
  return 0;
}
