
    Design an event recommendation algorithm that determines the number of possible ways to suggest n sequential events to users, where each event belongs to one of k interest categories, with the constraint that no more than 2 consecutive events can be from the same category to maintain engagement diversity. The goal is to maximize user engagement while preventing monotony in the recommendation sequence.
    

    
def count_no_of_ways(n, k):
    """
    Design an event recommendation algorithm that determines the number of possible ways to suggest n sequential events to users, where each event belongs to one of k interest categories, with the constraint that no more than 2 consecutive events can be from the same category to maintain engagement diversity. The goal is to maximize user engagement while preventing monotony in the recommendation sequence.
    

    """
def count_no_of_ways(n, k):
    """
    Design an event recommendation algorithm that determines the number of possible ways to suggest n sequential events to users, where each event belongs to one of k interest categories, with the constraint that no more than 2 consecutive events can be from the same category to maintain engagement diversity. The goal is to maximize user engagement while preventing monotony in the recommendation sequence.
    

    """
    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]