#include <bits/stdc++.h>
using namespace std;
struct edge {
  int t, f;
  long long w;
  bool operator<(const edge& e) const { return w > e.w; }
  edge(int from, int to, int weight) {
    t = to;
    f = from;
    w = weight;
  }
};
const double EPS = (1e-5);
int dcmp(double a, double b) { return fabs(a - b) <= EPS ? 0 : a < b ? -1 : 1; }
struct Double {
  double d;
  Double() { d = 0.0; };
  Double(double d) : d(d) {}
  bool operator<(const Double& D) const { return dcmp(d, D.d) < 0; }
  bool operator>(const Double& D) const { return dcmp(d, D.d) > 0; }
  bool operator==(const Double& D) const { return dcmp(d, D.d) == 0; }
};
bool intersectSegments(complex<double> a, complex<double> b, complex<double> c,
                       complex<double> d, complex<double>& intersect) {
  double d1 = ((conj(a - b) * (d - c)).imag()),
         d2 = ((conj(a - c) * (d - c)).imag()),
         d3 = ((conj(a - b) * (a - c)).imag());
  if (fabs(d1) < EPS) return false;
  double t1 = d2 / d1, t2 = d3 / d1;
  intersect = a + (b - a) * t1;
  if (t1 < -EPS || t2 < -EPS || t2 > 1 + EPS) return false;
  return true;
}
class UnionFind {
 public:
  vector<int> p, rank, setSize;
  int numSets;
  UnionFind(int N) {
    setSize.assign(N, 1);
    numSets = N;
    rank.assign(N, 0);
    p.assign(N, 0);
    for (int i = 0; i < N; i++) p[i] = i;
  }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      numSets--;
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y]) {
        p[y] = x;
        setSize[x] += setSize[y];
      } else {
        p[x] = y;
        setSize[y] += setSize[x];
        if (rank[x] == rank[y]) rank[y]++;
      }
    }
  }
  int numDisjointSets() { return numSets; }
  int sizeOfSet(int i) { return setSize[findSet(i)]; }
};
long long root(long long x) {
  long long l = 0, r = 1e9 + 1;
  while (l < r - 1) {
    long long m = (l + r) / 2;
    if (m * m > x)
      r = m;
    else
      l = m;
  }
  return l;
}
struct line {
  double a, b, c;
};
long long binpowmod(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
int findXOR(int n) {
  switch (n % 4) {
    case 0:
      return n;
    case 1:
      return 1;
    case 2:
      return n + 1;
    case 3:
      return 0;
  }
}
int rangeXOR(int l, int r) { return (findXOR(l - 1) ^ findXOR(r)); }
int getbit(int mask, int bit) { return (mask & (1 << bit)); }
void setbit(int& mask, int bit, int val) {
  if (val)
    mask |= (1 << bit);
  else
    mask &= ~(1 << bit);
}
const int N = 1e5 + 10;
const int M = 500 + 10;
const long long INF = 1e13 + 100;
const int MOD = 1e9 + 7;
class SegmentTree {
  struct node {
    int l, r, h;
    node() {
      l = 0;
      r = 0;
      h = 0;
    }
    node(int x) {
      l = 0;
      r = 0;
      h = 0;
      if (x == 1)
        l = 1;
      else
        r = 1;
    }
    node(int _l, int _r, int _h) {
      l = _l;
      r = _r;
      h = _h;
    }
  };

 private:
  vector<node> st;
  vector<int> lp;
  vector<int> A;
  int n;
  int left(int p) { return p << 1; }
  int right(int p) { return (p << 1) + 1; }
  node merge(node p1, node p2) {
    int l = p1.l + p2.l;
    int r = p1.r + p2.r;
    int x = min(p1.l, p2.r);
    l -= x;
    r -= x;
    return node(l, r, p1.h + p2.h + x);
  }
  node lazy(node x, int y) { return x; }
  void build(int p, int L, int R) {
    if (L == R) {
      st[p] = node(A[L]);
    } else {
      build(left(p), L, (L + R) / 2);
      build(right(p), (L + R) / 2 + 1, R);
      node p1 = st[left(p)], p2 = st[right(p)];
      st[p] = merge(p1, p2);
    }
  }
  node rmq(int p, int L, int R, int i, int j) {
    if (i > R || j < L) return node(-1, -1, -1);
    if (L >= i && R <= j) return st[p];
    node p1 = rmq(left(p), L, (L + R) / 2, i, j);
    node p2 = rmq(right(p), (L + R) / 2 + 1, R, i, j);
    if (p1.l == -1) return p2;
    if (p2.l == -1) return p1;
    return merge(p1, p2);
  }
  void update_point(int p, int L, int R, int idx, int v) {
    int i = idx, j = idx;
    if (i > R || j < L) return;
    if (L == i && R == j) {
      A[L] = v;
      st[p] = node(v);
      return;
    }
    node p1, p2;
    update_point(left(p), L, (L + R) / 2, idx, v);
    update_point(right(p), (L + R) / 2 + 1, R, idx, v);
    p1 = st[left(p)];
    p2 = st[right(p)];
    st[p] = merge(p1, p2);
  }
  void update_range(int p, int L, int R, int i, int j, int mode) {
    if (lp[p] != 0) {
      st[p] = lazy(st[p], lp[p]);
      if (L != R) {
        lp[left(p)] += lp[p];
        lp[right(p)] += lp[p];
      }
      lp[p] = 0;
    }
    if (i < L && j < L || i > R && j > R) return;
    if (L >= i && R <= j) {
      st[p] = lazy(st[p], mode);
      if (L != R) {
        lp[left(p)] += mode;
        lp[right(p)] += mode;
      }
      return;
    }
    update_range(left(p), L, (L + R) / 2, i, j, mode);
    update_range(right(p), (L + R) / 2 + 1, R, i, j, mode);
    st[p] = merge(st[left(p)], st[right(p)]);
  }

 public:
  SegmentTree(const vector<int>& _A) {
    A = _A;
    n = (int)A.size();
    st.assign(4 * n, node());
    lp.assign(4 * n, 0);
    build(1, 0, n - 1);
  }
  node rmq(int i, int j) { return rmq(1, 0, n - 1, i, j); }
  void update_point(int idx, int new_value) {
    update_point(1, 0, n - 1, idx, new_value);
  }
  void update_range(int i, int j, int mode) {
    update_range(1, 0, n - 1, i, j, mode);
  }
};
vector<vector<long long>> pas;
void pascal(int n) {
  pas.assign(n + 1, vector<long long>(n + 1));
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (i == j || !j)
        pas[i][j] = 1;
      else
        pas[i][j] = (pas[i - 1][j - 1] + pas[i - 1][j]) % MOD;
    }
  }
}
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  long long ans = 0;
  if (k > n || k == 1) {
    ans = binpowmod(m, n, MOD);
  } else if (k == n) {
    ans = binpowmod(m, (n + 1) / 2, MOD);
  } else {
    ans = m;
    if (k & 1) ans = (ans * ans) % MOD;
  }
  cout << ans << '\n';
}
int main(void) {
  pascal(2000);
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int tc = 1;
  while (tc--) {
    solve();
  }
}
