dp with dimensions [n+1][7][7] filled with -1 to represent uncomputed states.findSequences(index, last, prevLast) that returns the number of distinct sequences from the current index to n given the last two dice values last and prevLast.index is n, return 1 as the base case.dp[index][last][prevLast] is not -1, return its value as we have already computed this subproblem.i, check if it satisfies the conditions with last and prevLast. If it does, recursively call findSequences(index + 1, i, last) and add the result to the answer.dp[index][last][prevLast] before returning it.findSequences(0, 0, 0) to get the total number of distinct sequences and return this value modulo 10^9 + 7.