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

Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal.
A row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array).
 
Please complete the following python code precisely:
```python
class Solution:
    def equalPairs(self, grid: List[List[int]]) -> int:
```