After failing to clear his school mathematics examination, infinitepro decided to prepare very hard for his upcoming re-exam, starting with the topic he is weakest at ― computational geometry.
Being an artist, infinitepro has C$C$ pencils (numbered 1$1$ through C$C$); each of them draws with one of C$C$ distinct colours. He draws N$N$ lines (numbered 1$1$ through N$N$) in a 2D Cartesian coordinate system; for each valid i$i$, the i$i$-th line is drawn with the ci$c_i$-th pencil and it is described by the equation y=ai⋅x+bi$y = a_i \cdot x + b_i$.
Now, infinitepro calls a triangle truly-geometric if each of its sides is part of some line he drew and all three sides have the same colour. He wants to count these triangles, but there are too many of them! After a lot of consideration, he decided to erase a subset of the N$N$ lines he drew. He wants to do it with his eraser, which has length K$K$.
Whenever erasing a line with a colour i$i$, the length of the eraser decreases by Vi$V_i$. In other words, when the eraser has length k$k$ and we use it to erase a line with a colour i$i$, the length of the eraser decreases to k−Vi$k-V_i$; if k<Vi$k < V_i$, it is impossible to erase such a line.
Since infinitepro has to study for the re-exam, he wants to minimise the number of truly-geometric triangles. Can you help him find the minimum possible number of truly-geometric triangles which can be obtained by erasing a subset of the N$N$ lines in an optimal way? He promised a grand treat for you if he passes the examination!

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of the input contains three space-separated integers N$N$, C$C$ and K$K$.
- N$N$ lines follow. For each i$i$ (1≤i≤N$1 \le i \le N$), the i$i$-th of these lines contains three space-separated integers ai$a_i$, bi$b_i$ and ci$c_i$.
- The last line contains C$C$ space-separated integers V1,V2,…,VC$V_1, V_2, \ldots, V_C$.

-----Output-----
For each test case, print a single line containing one integer ― the smallest possible number of truly-geometric triangles after erasing lines.

-----Constraints-----
- 1≤T≤10$1 \le T \le 10$
- 1≤C≤N≤3,000$1 \le C \le N \le 3,000$
- 0≤K≤3,000$0 \le K \le 3,000$
- 0≤ai,bi≤109$0 \le a_i, b_i \le 10^9$ for each valid i$i$
- 1≤ci≤C$1 \le c_i \le C$ for each valid i$i$
- 0≤Vi≤K$0 \le V_i \le K$ for each valid i$i$
- no two lines coincide, regardless of their colours
- no three lines are concurrent

-----Subtasks-----
Subtask #1 (10 points):
- N≤10$N \le 10$
- K≤100$K \le 100$
Subtask 2 (15 points):
- V1=V2=…=VC$V_1 = V_2 = \ldots = V_C$
- no two lines are parallel
Subtask #3 (25 points): no two lines are parallel
Subtask #4 (50 points): original constraints

-----Example Input-----
2
7 2 13
1 10 1
1 14 2
6 4 1
2 2 1
0 12 2
2 11 2
0 6 1
8 10
6 1 20
1 5 1
2 11 1
4 0 1
6 8 1
0 11 1
3 3 1
9

-----Example Output-----
2
4

-----Explanation-----
Example case 1: We can remove exactly one line. Initially, we have 5$5$ truly geometric triangles (see the image below; red is colour 1$1$ and green is colour 2$2$).
- Removing any line with colour 2$2$ brings the total number of truly-geometric triangles down to 4+0=4$4+0=4$.
- Removing any line with colour 1$1$ brings the total number of truly-geometric triangles down to 1+1=2$1+1=2$.
Thus, the smallest number of truly-geometric triangles we can obtain is 2$2$.

Example case 2: We can remove at most 2$2$ lines and removing any 2$2$ lines gives us a total of 4$4$ truly-geometric triangles.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# cook your dish here\r\nimport collections\r\nfrom itertools import combinations\r\ndef checkintersection(e1,e2,e3):\r\n    if (e1[0]-e2[0])!=0:\r\n        x1=(e1[1]-e2[1])/(e1[0]-e2[0])\r\n        y1=e1[0]*x1+e1[1]\r\n    else:\r\n        return True\r\n    if (e2[0]-e3[0])!=0:\r\n        x2=(e2[1]-e3[1])/(e2[0]-e3[0])\r\n        y2=e2[0]*x2+e2[1]\r\n    else:\r\n        return True\r\n    return (x1==x2) and (y1==y2)\r\ndef checkparallel(m1,m2,m3):\r\n    return (m1==m2) or (m2==m3) or (m1==m3)\r\n\r\nfor _ in range(int(input())):\r\n    N,C,K=map(int,input().split())\r\n    A=[]\r\n    D={}\r\n    EQ={}\r\n    for i in range(N):\r\n        a,b,c=map(int,input().split())\r\n        if c not in D:D[c]=[]\r\n        D[c].append((a,b,c))\r\n        EQ[(a,b,c)]=0 \r\n    V=list(map(int,input().split()))\r\n    V.insert(0,0)\r\n    nextflag=1\r\n    while K>=0 and nextflag==1:\r\n        nextflag=0\r\n        ans=0\r\n        for col in D:\r\n            if len(D[col])>=3:\r\n                triangles=list(combinations(D[col],3))\r\n                triangles=list(set(triangles))\r\n                for tri in triangles:\r\n                    boolp=checkparallel(tri[0][0],tri[1][0],tri[2][0])\r\n                    booli=checkintersection(tri[0],tri[1],tri[2])\r\n                    if boolp==False and booli==False:    #Triangle\r\n                        EQ[tri[0]]+=1\r\n                        EQ[tri[1]]+=1\r\n                        EQ[tri[2]]+=1\r\n                        ans+=1\r\n        EQ={k: v for k, v in sorted(EQ.items(), key=lambda item: item[1],reverse=True)}\r\n        for i in EQ:\r\n            e=i \r\n            if V[e[2]]<=K:\r\n                K-=V[e[2]]\r\n                nextflag=1\r\n                D[e[2]].remove(e)\r\n                del EQ[i]\r\n                break\r\n    print(ans)\r\n    \r\n                \r\n        \r\n        \r\n    '
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14409