[Python] Faster then 100%
The mats are the transition matrices I calculated using other codes.\n\n\nimport numpy\nmats=[None,None,None,numpy.array([[3, 2], [2, 2]]),\n    numpy.array([[3
The `mats` are the transition matrices I calculated using other codes.\n\n```\nimport numpy\nmats=[None,None,None,numpy.array([[3, 2], [2, 2]]),\n    numpy.array([[3, 2, 1, 2], [2, 2, 1, 2], [1, 1, 2, 1], [2, 2, 1, 2]]),\n    numpy.array([[3, 2, 2, 1, 0, 1, 2, 2], [2, 2, 2, 1, 1, 1, 1, 1], [2, 2, 2, 1, 0, 1, 2, 2], [1, 1, 1, 2, 1, 1, 1, 1], [0, 1, 0, 1, 2, 1, 0, 1], [1, 1, 1, 1, 1, 2, 1, 1], [2, 1, 2, 1, 0, 1, 2, 1], [2, 1, 2, 1, 1, 1, 1, 2]])]\nclass Solution:\n    def colorTheGrid(self, m: int, n: int) -> int:\n        if m==1:\n            return int(6*2**(n-2))%(1000000007)\n        elif m==2:\n            return 6*int(3**(n-1))%(1000000007)\n        mat=mats[m]\n        v=numpy.array([1 for i in range(len(mat))])\n        for i in range(n-1):\n            v=numpy.array([j%1000000007 for j in mat.dot(v)])\n        return 6*sum(v)%1000000007\n```
['Dynamic Programming', 'Matrix']