#include <bits/stdc++.h>
using namespace std;
long long n, m, k, q, i, res, a[3000], j, z;
long long b[3000];
int main() {
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    q = n;
  else if (k % 2 == 1) {
    if (n == k)
      q = n / 2 + n % 2;
    else
      q = 2;
  } else if (k % 2 == 0) {
    if (n == k)
      q = n / 2;
    else
      q = 1;
  }
  res = 1;
  for (i = 1; i <= q; i++) {
    res = res * m;
    res = res % 1000000007;
  }
  cout << res;
  return 0;
}
