There are n persons located on a plane. The i-th person is located at the point (x_i, y_i) and initially looks at the point (u_i, v_i).

At the same moment of time, all persons will start to rotate clockwise synchronously with the same angular speed. They will rotate until they do one full 360-degree turn. 

It is said that persons A and B made eye contact if person A looks in person B's direction at the same moment when person B looks in person A's direction. If there is a person C located between persons A and B, that will not obstruct A and B from making eye contact. A person can make eye contact with more than one person at the same time.

Calculate the number of pairs of persons that will make eye contact at least once during the rotation (including the initial moment).

Input

The first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases.

The first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of persons. The following n lines describe persons, each line containing four space-separated integers x_i, y_i, u_i, v_i (|x_i|, |y_i|, |u_i|, |v_i| ≤ 10^9; x_i ≠ u_i or y_i ≠ v_i), where (x_i, y_i) are the coordinates of the point where the i-th person is located and (u_i, v_i) are the coordinates of the point that the i-th person looks at initially. Each person's location is unique in each test case.

The sum of n over all test cases does not exceed 10^5.

Output

For each test case, print one integer — the number of pairs of persons who will make eye contact at least once during the rotation, including the initial moment.

Example

Input


3
2
0 0 0 1
1 0 2 0
3
0 0 1 1
1 1 0 0
1 0 2 0
6
0 0 0 1
1 0 1 2
2 0 2 3
3 0 3 -5
4 0 4 -5
5 0 5 -5


Output


0
1
9
import java.util.*;
import java.io.*;  
import java.util.Map.Entry;
 
public class Solution{
    // public static class pair{
    //     int x;
    //     int y;
    // }
    public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
        public String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}public double nextDouble() {
			return Double.parseDouble(next());
		}
    }
    public static class Pair implements Comparable<Pair>{
        private int x;
        private int y;
        public Pair(int a,int b){
            x=a;
            y=b;
        }
        public Pair clone() {
			return new Pair(x, y);
		}
        @Override
		public int compareTo(Pair o) {
			if (x > o.x) {
				return 1;
			}
			if (x < o.x) {
				return -1;
			}
			if (y > o.y) {
				return 1;
			}
			if (y < o.y) {
				return -1;
			}
			return 0;
		}
    }
    static long[] fac=fact();
    static long[] fact(){
        long[] fac = new long[200001];
        fac[0] = (long)1;
        for (int i = 1; i < (int)fac.length; i++){
            fac[i] = (fac[i - 1] * i) % 1000000007;
        }
        return fac;
    }
    public static void main(String[] args) throws IOException{
        FastScanner fs=new FastScanner();
		int t=fs.nextInt();
		PrintWriter out=new PrintWriter(System.out);
		while(t-->0){
		    int n=fs.nextInt();
		    TreeMap<Pair,Integer> map=new TreeMap<>();
		    for(int i=0;i<n;i++){
		        int x=fs.nextInt();
		        int y=fs.nextInt();
		        int u=fs.nextInt();
		        int v=fs.nextInt();
		        u-=x;
		        v-=y;
		        int gcd=gcd(Math.abs(u),Math.abs(v));
		      //  System.out.println(gcd);
		        if(gcd!=0){
		            u/=gcd;
		            v/=gcd;
		        }
		        Pair p=new Pair(u,v);
		        if (!map.containsKey(p))
 					map.put(p, 0);
 				map.put(p,  map.get(p)+1);
		    }
		    long ans=0;
		    for(Pair p:map.keySet()){
		        if(map.containsKey(new Pair(-p.x,-p.y))){
		            int num=map.get(new Pair(-p.x,-p.y));
		            ans+=(num*1L*map.get(p));
		        }
		    }
		    System.out.println(ans/2);
// 		  TreeMap<Pair, Integer> map = new TreeMap<>();
// 			for (int i = 0; i < n; i++) {
// 				int x1 = fs.nextInt();
// 				int y1 = fs.nextInt();
// 				int dx = fs.nextInt() - x1;
// 				int dy = fs.nextInt() - y1;
// 				int gcd = (int) gcd(Math.abs(dx), Math.abs(dy));
// 				dx /= gcd;
// 				dy /= gcd;
// 				Pair cur = new Pair(dx, dy);
// 				if (map.containsKey(cur)) {
// 					map.put(cur, map.get(cur) + 1);
// 				} else {
// 					map.put(cur, 1);
// 				}
// 			}
// 			long ans = 0;
// 			for (Entry<Pair, Integer> e : map.entrySet()) {
// 				if (map.containsKey(new Pair(-e.getKey().x, -e.getKey().y))) {
// 					ans += map.get(new Pair(-e.getKey().x, -e.getKey().y)) * 1L * e.getValue();
// 				}
// 			}
// 			out.println(ans / 2);
		}
        out.close();
    }
    public static boolean getans(int v,int[] arr,int b,int a){
        int low=Math.min(a,b);
        int high=Math.max(a,b)-2;
        int t=low;
        int ans=0;
        int i=0;
        while(i<arr.length){
            // System.out.println(arr[i]+" "+t);
            if(arr[i]<=t){
                t++;
                ans++;
                i++;
            }else{
                t=arr[i];
            }
            if(t>high){
                break;
            }
        }
        // if(v==2){
        //     System.out.println(ans+" "+low+" "+high);
        // }
        if(v==3){
            // System.out.println(ans);
        }
        if(ans>=v){
            return true;
        }
        return false;
    }
    public static String call(int in,char[] arr){
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<in;i++){
            sb.append(arr[i]+"");
        }
        sb.append(arr[arr.length-1]+"");
        for(int i=in+1;i<arr.length-1;i++){
            sb.append(arr[i]+"");
        }
        sb.append(arr[in]+"");
        return sb.toString();
    }
    // public static long gcdFind(long[] arr){
    //     long result = (long)0; 
    //     for (long element: arr){ 
    //         result = gcd(result, element);
  
    //         if(result == (long)1) 
    //         { 
    //           return 1; 
    //         } 
    //     } 
    //     return result;
    // }
    public static int dfs(int in,ArrayList<Integer>[] adj,HashSet<Integer> set,HashMap<Integer,Integer> vis){
        if(vis.containsKey(in)){
            return 1;
        }
        if(set.contains(in)){
            return 0;
        }
        vis.put(in,1);
        ArrayList<Integer> l=adj[in-1];
        if(l.size()==0){
            return 2;
        }
        return dfs(l.get(0),adj,set,vis);
    }
    public static boolean check(long n){
        String s=n+"";
        HashMap<Integer,Integer> set=new HashMap<>();
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)!='0'){
                set.put(s.charAt(i)-'0',1);
            }
        }
        for(int key:set.keySet()){
            if(n%key!=0){
                return false;
            }
        }
        return true;
    }
    public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<>();
		for(int i:array){
			copy.add(i);
		}
		Collections.sort(copy);
		for(int i=0;i<array.length;i++){
			array[i]=copy.get(i);
		}
	}
    static long power(long x, long y, long p){
        long res = 1;
        x = x % p;
        while (y > 0) {
            if (y % 2 == 1)
                res = (res * x) % p;
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }
        return res;
    }
    public static long modInverse(long n, long p){
        return power(n, p - 2, p);
    }
    public static long nCr(long n, long r,long p){
        if (n<r) 
              return (long)0;
        if (r == 0)
            return (long)1;
        return (fac[(int)n] * modInverse(fac[(int)r], p)% p * modInverse(fac[(int)(n - r)], p)% p)% p;
    }
    public static int upp(int[] arr,int v){
        int low=0;
        int high=arr.length-1;
        int ans=-1;
        while(low<=high){
            int m=(low+high)/2;
            if(arr[m]<v){
                ans=m;
                low=m+1;
            }else{
                high=m-1;
            }
        }
        return ans+1;
    }
    public static int low(int[] arr,int v){
        int low=0;
        int high=arr.length-1;
        int ans=-1;
        while(low<=high){
            int m=(low+high)/2;
            if(arr[m]>v){
                ans=m;
                high=m-1;
            }else{
                low=m+1;
            }
        }
        return ans;
    }
    public static class Comp implements Comparator<Pair>{
        public int compare(Pair a,Pair b){
            if(a.y==b.y){
                return a.x-b.x;
            }else{
                return b.y-a.y;
            }
        }
    }
    public static int gcd(int a,int b){
        if (b == 0) 
        return a; 
        return gcd(b, a % b);
    }
    public static int lcm(int a,int b){
        int x=Math.max(a,b);
        int y=Math.min(a,b);
        long ans=x;
        while(ans%y!=0){
            ans+=x;
        }
        if(ans>Integer.MAX_VALUE){
            return -1;
        }
        return (int)ans;
    }
    public static long fact(int n){
        long ans=1;
        for(int i=1;i<=n;i++){
            ans*=i;
        }
        return ans;
    }
}