Python3 Solution
\n\nclass Solution:\n    def spiralMatrixIII(self, rows: int, cols: int, rStart: int, cStart: int) -> List[List[int]]:\n        ans=[]\n        dx,dy,n=0,1,0\n 
\n```\nclass Solution:\n    def spiralMatrixIII(self, rows: int, cols: int, rStart: int, cStart: int) -> List[List[int]]:\n        ans=[]\n        dx,dy,n=0,1,0\n        while len(ans)<rows*cols:\n            for i in range(n//2+1):\n                if 0<=rStart<rows and 0<=cStart<cols:\n                    ans.append([rStart,cStart])\n                rStart=rStart+dx\n                cStart=cStart+dy\n            dx,dy,n=dy,-dx,n+1\n        return ans                    \n```
['Python', 'Python3']