class Solution:
    def largestOverlap(self, A: List[List[int]], B: List[List[int]]) -> int:
        N = len(A)
        count=collections.Counter()
        for i,row, in enumerate(A):
            for j,v in enumerate(row):
                if v:
                    for i2,row2 in enumerate(B):
                        for j2,v2 in enumerate(row2):
                            if v2:
                                count[i-i2,j-j2]+=1
        return max(count.values() or [0])
0c1ca80daf06d45ca78ca54dfffd99e167ed6746
<mask token>

class Solution:
    <mask token>

class Solution:

    def largestOverlap(self, A: List[List[int]], B: List[List[int]]) ->int:
        N = len(A)
        count = collections.Counter()
        for i, row in enumerate(A):
            for j, v in enumerate(row):
                if v:
                    for i2, row2 in enumerate(B):
                        for j2, v2 in enumerate(row2):
                            if v2:
                                count[i - i2, j - j2] += 1
        return max(count.values() or [0])

class Solution:
    def largestOverlap(self, A: List[List[int]], B: List[List[int]]) -> int:
        N = len(A)
        count=collections.Counter()
        for i,row, in enumerate(A):
            for j,v in enumerate(row):
                if v:
                    for i2,row2 in enumerate(B):
                        for j2,v2 in enumerate(row2):
                            if v2:
                                count[i-i2,j-j2]+=1
        return max(count.values() or [0])