import scala.io.StdIn._

object Main extends App {
  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  val mod = 1000000007
  var sum = 1L
  for (_ ← 0 until n) {
    sum *= k
    sum %= mod
  }
  println(sum)
}

