from typing import List
from typing import Counter


def count_four_sum(A: List[int], B: List[int], C: List[int], D: List[int]) -> int:
    """https://leetcode.com/problems/4sum-ii/"""

    counter_ab = Counter(a+b for a in A for b in B)
    return sum(counter_ab[-(c+d)] for c in C for d in D)