
    Design a system to determine the number of possible student risk assessment patterns across n checkpoints throughout the academic year, where each checkpoint can classify a student into one of k risk categories, with the constraint that a student cannot be classified in the same risk category for more than two consecutive checkpoints. The goal is to identify all valid sequences of risk classifications that could help track and intervene in potential dropout cases while avoiding prolonged periods of sustained high-risk status.
    

    
def count_no_of_ways(n, k):
    """
    Design a system to determine the number of possible student risk assessment patterns across n checkpoints throughout the academic year, where each checkpoint can classify a student into one of k risk categories, with the constraint that a student cannot be classified in the same risk category for more than two consecutive checkpoints. The goal is to identify all valid sequences of risk classifications that could help track and intervene in potential dropout cases while avoiding prolonged periods of sustained high-risk status.
    

    """
def count_no_of_ways(n, k):
    """
    Design a system to determine the number of possible student risk assessment patterns across n checkpoints throughout the academic year, where each checkpoint can classify a student into one of k risk categories, with the constraint that a student cannot be classified in the same risk category for more than two consecutive checkpoints. The goal is to identify all valid sequences of risk classifications that could help track and intervene in potential dropout cases while avoiding prolonged periods of sustained high-risk status.
    

    """
    dp = [0] * (n + 1)
    total = k
    mod = 1000000007
    dp[1] = k
    dp[2] = k * k
    for i in range(3, n + 1):
        dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod
    return dp[n]