// Arup Guha
// 2/7/2018
// Solution to 2018 January USACO Gold Problem: Stamp Painting

import java.util.*;
import java.io.*;

public class spainting {

	final public static long MOD = 1000000007L;

	public static void main(String[] args) throws Exception {

		// Read input.
		Scanner stdin = new Scanner(new File("spainting.in"));
		int n = stdin.nextInt();
		long m = stdin.nextLong();
		int k = stdin.nextInt();

		// Output to file.
		PrintWriter out = new PrintWriter(new FileWriter("spainting.out"));
		out.println(solve(n, m, k));
		out.close();
		stdin.close();
	}

	// Returns solution to query.
	public static long solve(int n, long m, int k) {

		// Weird case.
		if (k > n) return m;

		// index i stores how many combos are ok or bad of length i.
		long[] ok = new long[n+1];
		long[] bad = new long[n+1];
		bad[0] = 1;

		long mpow = 1;

		// Up to k-1 all solutions are bad.
		for (int i=1; i<k; i++) {
			bad[i] = (bad[i-1]*m)%MOD;
			mpow = (mpow*m)%MOD;
		}

		// Special case for me.
		mpow = (mpow*m)%MOD;
		ok[k] = m;
		bad[k] = (mpow-m+MOD)%MOD;

		// Here is how you build the rest.
		for (int i=k+1; i<=n; i++) {

			// All old okay streaks can continue in m ways.
			// Bad streaks of length i-k can be made good in m-1 ways (all but the last color...)
			ok[i] = ((ok[i-1]*m)%MOD + (bad[i-k]*(m-1))%MOD)%MOD;

			// Update and recalculating bad is easy - whole minus ok.
			mpow = (mpow*m)%MOD;
			bad[i] = (mpow - ok[i] + MOD)%MOD;
		}

		return ok[n];
	}
}