<p>There is a street with <code>n * 2</code> <strong>plots</strong>, where there are <code>n</code> plots on each side of the street. The plots on each side are numbered from <code>1</code> to <code>n</code>. On each plot, a house can be placed.</p>

<p>Return <em>the number of ways houses can be placed such that no two houses are adjacent to each other on the same side of the street</em>. Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>

<p>Note that if a house is placed on the <code>i<sup>th</sup></code> plot on one side of the street, a house can also be placed on the <code>i<sup>th</sup></code> plot on the other side of the street.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 1
<strong>Output:</strong> 4
<strong>Explanation:</strong> 
Possible arrangements:
1. All plots are empty.
2. A house is placed on one side of the street.
3. A house is placed on the other side of the street.
4. Two houses are placed, one on each side of the street.
</pre>

<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2022/05/12/arrangements.png" style="width: 500px; height: 500px;" />
<pre>
<strong>Input:</strong> n = 2
<strong>Output:</strong> 9
<strong>Explanation:</strong> The 9 possible arrangements are shown in the diagram above.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 10<sup>4</sup></code></li>
</ul>

MOD = 10**9+7

class Solution:
    def countHousePlacements(self, n: int) -> int:
        one = self.fibMatrix(n+ 2)
        return one * one % MOD
    
    def fibMatrix(self, n: int) -> int:
        vector = [0, 1]
        m = [0, 1, 1, 1]
        num = n
        while num > 0:
            if num % 2 == 1:
                vector = self.vectorMatrixMul(vector=vector, matrix=m)
            m = self.matrixMul(m)
            num= num // 2

        return vector[0] % MOD
    
    def matrixMul(self, m: List[int]) -> List[int]:
        a, b, c, d = [x % MOD for x in m]
        return [a*a+b*c, a*b+b*d, c*a+d*c, c*b+d*d]
    
    def vectorMatrixMul(self, vector: List[int], matrix: List[int]) -> List[int]:
        a, b, c, d = [x % MOD for x in matrix]
        e, f = [x % MOD for x in vector]
        return [a*e+b*f, c*e+d*f]
36