class Solution:
def equalPairs(self, grid: List[List[int]]) -> int:
c=[]
for i in range(len(grid)):
l=[]
for j in range(len(grid[i])):
l.append(grid[j][i]) #varying the row in grid to get all column elements
c.append(l) #appending column
res=0
for i in grid:
if i in c: #i: column element
res=res+c.count(i) #not res+1 since multiple i's might be present
return res