#include <bits/stdc++.h>
using namespace std;
long long n, m, k, ans;
int f[3000], i, j, x, y;
long long p(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % 1000000007;
    a = a * a % 1000000007;
    b /= 2;
  }
  return ans;
}
int find(int x) {
  if (x == f[x]) return x;
  f[x] = find(f[x]);
  return f[x];
}
int main() {
  cin >> n >> m >> k;
  if (k > n) {
    cout << p(m, n) << endl;
    return 0;
  }
  if (k == 1) {
    cout << p(m, n) << endl;
  } else if (k == 2) {
    cout << m << endl;
  } else {
    for (int i = 1; i <= min(2 * k, n); ++i) f[i] = i;
    for (int i = 1; i <= k / 2; ++i) {
      x = i;
      y = k - i + 1;
      x = find(x);
      y = find(y);
      if (x != y) f[x] = y;
    }
    for (int i = 2; i <= min(k + 1, n); ++i) {
      if (i + k - 1 <= n) {
        int l = i, r = i + k - 1;
        while (l < r) {
          x = find(l);
          y = find(r);
          if (x != y) f[x] = y;
          l++;
          r--;
        }
      }
    }
    ans = 0;
    for (int i = 1; i <= min(2 * k, n); ++i)
      if (find(i) == i) ans++;
    cout << p(m, ans) << endl;
  }
  return 0;
}
