1import numpy as np234class Solution:56def checkRecord(self, n: int) -> int:7MODULUS = 10**9 + 789initial_counts = np.array([1, 0, 0, 0, 0, 0], dtype=np.int64)1011adjacency_matrix = np.array(12[13[1, 1, 1, 0, 0, 0],14[1, 0, 0, 0, 0, 0],15[0, 1, 0, 0, 0, 0],16[1, 1, 1, 1, 1, 1],17[0, 0, 0, 1, 0, 0],18[0, 0, 0, 0, 1, 0],19],20dtype=np.int64,21)2223def power(A, exp):24B = np.identity(len(A), dtype=np.int64)25for bit in reversed(bin(exp)[2:]):26if bit == "1":27B = B @ A28B %= MODULUS29A = A @ A30A %= MODULUS31return B3233final_counts = power(adjacency_matrix, n) @ initial_counts3435return sum(final_counts) % MODULUS