Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def mod_fra(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def mod_power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return mod_power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * mod_power(n, r-1, mod) % mod

def mod_comb(n, k, mod):
    a=mod_fra(n, mod)
    b=mod_fra(k, mod)
    c=mod_fra(n-k, mod)
    return (a * mod_power(b, mod-2, mod) * mod_power(c, mod-2, mod)) % mod
def main():
    n,m,k=map(int,input().split())
    mod=998244353
    ans=0
    for kx in range(k+1):
        ans+=mod_comb(n-1,kx,mod)*m*(m-1)**(n-1-kx)%mod
    print(ans%mod)


if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
class Facts:
  def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      setup_table(n_max) 
  
  def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod
  
  def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[self.mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

def main():
    n,m,k=map(int,input().split())
    mod=998244353
    f=Facts(mod)
    ans=0
    t=m*pow(m-1,n-1-k,mod)
    for kx in range(k,-1,-1):
        ans+=f.cmb(n-1,kx)*t%mod
        t=t*(m-1)%mod
    print(ans%mod)


if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def mod_fra(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def mod_power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return mod_power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * mod_power(n, r-1, mod) % mod

def mod_comb(n, k, mod):
    a=mod_fra(n, mod)
    b=mod_fra(k, mod)
    c=mod_fra(n-k, mod)
    return (a * mod_power(b, mod-2, mod) * mod_power(c, mod-2, mod)) % mod
def main():
    n,m,k=map(int,input().split())
    mod=998244353
    ans=0
    for kx in range(k+1):
        ans+=mod_comb(n-1,kx,mod)*m*(m-1)**(n-1-kx)%mod
    print(ans%mod)


if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
class Facts:
  def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      setup_table(n_max) 
  
  def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod
  
  def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[self.mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

def main():
    n,m,k=map(int,input().split())
    mod=998244353
    f=Facts(mod)
    ans=0
    t=m*pow(m-1,n-1-k,mod)
    for kx in range(k,-1,-1):
        ans+=f.cmb(n-1,kx)*t%mod
        t=t*(m-1)%mod
    print(ans%mod)


if __name__=='__main__':
    main()