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.lang.*;
import java.io.*;

public class Jan5 {

	public static void main(String[] args) throws Exception {

//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		int t = Integer.parseInt(br.readLine());
//		StringBuilder sb = new StringBuilder();
//		while (t-- > 0) {
//			String[] scn = (br.readLine()).trim().split(" ");
//			int n = Integer.parseInt(scn[0]);
//			long[] arr = new long[n];
//			scn = (br.readLine()).trim().split(" ");
//			for (int i = 0; i < n; i++) {
//				arr[i] = Long.parseLong(scn[i]);
//			}
//			sb.append("\n");
//		}
//		System.out.println(sb);
//		return;

//		first();
//		sec();
//		third();
//		four();
		fif();
//			six();
	}

	private static void first() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine());
		ArrayList<Long> list = new ArrayList<>();
		long temp = n;
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0) {
				long fact = 1;
				while (n % i == 0) {
					fact *= i;
					n /= i;
				}
				list.add(fact);
			}
		}
		list.add(n);
		long a = fun(1, 1, list, 0, list.size(), 2);
		System.out.println(temp / a + " " + a);
		return;
	}

	public static long fun(long a, long b, ArrayList<Long> list, int i, int n, int k) {
		if (i == n) {
			return Math.max(a, b);
		}
		long ra = fun(a * list.get(i), b, list, i + 1, n, k);
		long rb = fun(a, b * list.get(i), list, i + 1, n, k);
		return Math.min(ra, rb);
	}

	private static void sec() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String orig = br.readLine();
		String rec = br.readLine();
		int n = orig.length();
		int pos = 0, count = 0;
		for (int i = 0; i < n; i++) {
			char ch = orig.charAt(i);
			if (ch == '+')
				pos += 1;
			else
				pos -= 1;
			if (rec.charAt(i) == '?') {
				count += 1;
			}
		}

		double reach = fun_2(rec, "", 0, n, pos);
		double ans = reach / Math.pow(2, count);
		System.out.println(String.format("%.9f", ans));

		return;
	}

	public static int fun_2(String orig, String changed, int i, int n, int pos) {
		if (i == n) {
			int npos = 0;
			for (char ch : changed.toCharArray()) {
				if (ch == '+')
					npos += 1;
				else
					npos -= 1;
			}
			changed = "";
			if (npos == pos)
				return 1;
			else
				return 0;
		}
		if (orig.charAt(i) == '?') {
			int a = fun_2(orig, changed + "+", i + 1, n, pos);
			int b = fun_2(orig, changed + "-", i + 1, n, pos);
			return a + b;
		} else if (orig.charAt(i) == '+') {
			return fun_2(orig, changed + "+", i + 1, n, pos);
		} else if (orig.charAt(i) == '-') {
			return fun_2(orig, changed + "-", i + 1, n, pos);
		}
		return 0;
	}

	private static void third() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			long[] arr = new long[n];
			scn = (br.readLine()).trim().split(" ");
			HashSet<Long> set = new HashSet<>();
			for (int i = 0; i < n; i++) {
				arr[i] = Long.parseLong(scn[i]);
				set.add(arr[i]);
			}
			int ans = 0;
			for (int dig = 1; dig < 1030; dig++) {
				boolean can = true;
				for (int i = 0; i < n; i++) {
					long newnum = (dig ^ arr[i]);
					if (!set.contains(newnum)) {
						can = false;
						break;
					}
				}
				if (can) {
					ans = dig;
					break;
				}
			}
			if (ans == 0)
				sb.append("-1");
			else
				sb.append(ans);
			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	private static void four() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String str = br.readLine();
			int n = str.length();
			ArrayList<Pair> list = new ArrayList<>();
			int x = 0, y = 0;
			for (int i = 0; i < n; i++) {
				if (str.charAt(i) == 'U') {
					y += 1;
				} else if (str.charAt(i) == 'D') {
					y -= 1;
				} else if (str.charAt(i) == 'R') {
					x += 1;
				} else if (str.charAt(i) == 'L') {
					x -= 1;
				}
				list.add(new Pair(x, y));
			}
			int idx = 0;
			for (idx = 0; idx < list.size(); idx++) {
				int obx = list.get(idx).x;
				int oby = list.get(idx).y;
				x = 0;
				y = 0;
				for (int i = 0; i < n; i++) {
					if (str.charAt(i) == 'U' && !(x == obx && y + 1 == oby)) {
						y += 1;
					} else if (str.charAt(i) == 'D' && !(x == obx && y - 1 == oby)) {
						y -= 1;
					} else if (str.charAt(i) == 'R' && !(x + 1 == obx && y == oby)) {
						x += 1;
					} else if (str.charAt(i) == 'L' && !(x - 1 == obx && y == oby)) {
						x -= 1;
					}
				}
				if (x == 0 && y == 0) {
					x = obx;
					y = oby;
					break;
				}
			}
			if (idx != n)
				sb.append(x + " " + y);
			else
				sb.append("0 0");

			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	static class Pair {
		int x, y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

	}

	private static void fif() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			HashMap<Double, Long> map = new HashMap<>();
			HashMap<Double, Long> opp = new HashMap<>();
			for (int i = 0; i < n; i++) {
				scn = (br.readLine()).trim().split(" ");
				int x1 = Integer.parseInt(scn[0]);
				int y1 = Integer.parseInt(scn[1]);
				int x2 = Integer.parseInt(scn[2]);
				int y2 = Integer.parseInt(scn[3]);
				double a = Math.atan((double) (y2 - y1) / (double) (x2 - x1));
				if (x2 - x1 > 0) {
					opp.put(a, opp.getOrDefault(a, 0l) + 1);
				} else {
					map.put(a, map.getOrDefault(a, 0l) + 1);
				}
			}
//			System.out.println(map);
//			System.out.println(opp);
			long count = 0;
			for (double key : map.keySet()) {
				if (map.containsKey(key + Math.PI)) {
					count += (map.get(key) * map.get(key + Math.PI));
				}
				if (opp.containsKey(key)) {
					count += (map.get(key) * opp.get(key));
				}
				if(key == -0.0 && opp.containsKey(0.0)) {
					count += (map.get(key) * opp.get(0.0));
					
				}
			}
			sb.append(count);
			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	private static void six() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			String[] scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			long[] arr = new long[n];
			scn = (br.readLine()).trim().split(" ");
			for (int i = 0; i < n; i++) {
				arr[i] = Long.parseLong(scn[i]);
			}

			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	public static void sort(long[] arr) {
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			int idx = (int) Math.random() * n;
			long temp = arr[i];
			arr[i] = arr[idx];
			arr[idx] = temp;
		}
		Arrays.sort(arr);
	}
}
