n=int(input())
a=set()
b=set()
c=set()
d=set()
for i in range(n):
    aa,bb,cc,dd=map(int,input().split(' '))
    a.add(aa)
    b.add(bb)
    c.add(cc)
    d.add(dd)

res=0
for i in a:
    for j in b:
        for k in c:
            if 0-i-j-k in d:
                res+=1
print(res)