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