Please solve the programming task below using a self-contained code snippet in a markdown code block.

Given an m x n integer matrix grid where each entry is only 0 or 1, return the number of corner rectangles.
A corner rectangle is four distinct 1's on the grid that forms an axis-aligned rectangle. Note that only the corners need to have the value 1. Also, all four 1's used must be distinct.
 
Please complete the following python code precisely:
```python
class Solution:
    def countCornerRectangles(self, grid: List[List[int]]) -> int:
```