// Arup Guha
// 1/20/2013
// Solution to 2011 Mercer Problem 5: Marbles

import java.util.*;

// Used to sort marbles.
class pair implements Comparable<pair> {

	public int x;
	public int y;
	public double slope;
	public int ID;

	public pair(int first, int second) {
		x = first;
		y = second;

		// Fix vertical lines =)
		if (x == 0)
			slope = 1000000;
		else
			slope = (double)y/x;
	}

	// Sort by slope.
	public int compareTo(pair other) {
		if (this.slope < other.slope-1e-7)
			return -1;
		else if (this.slope > other.slope+1e-7)
			return 1;
		return 0;
	}

	public String toString() {
		return "("+x+","+y+")";
	}
}

public class prob5 {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		for (int loop=0; loop<numCases; loop++) {

			int pts = stdin.nextInt();

			// Read in marbles.
			pair[] marbles = new pair[pts];
			for (int i=0; i<pts; i++) {
				int x = stdin.nextInt();
				int y = stdin.nextInt();
				marbles[i] = new pair(x,y);
			}

			int cnt = 0;

			// Start is first pt in 3 marbles in a row
			for (int start=0; start<pts-2; start++) {

				// Calculate slopes to all points from pt[start].
				pair[] slopes = new pair[pts-1-start];
				for (int i=0; i<slopes.length; i++) {
					slopes[i] = new pair(marbles[start+1+i].x-marbles[start].x, marbles[start+1+i].y-marbles[start].y);
				}
				Arrays.sort(slopes);

				int begin = 0;
				int end = begin;

				// Iterate through slopes.
				while (begin < slopes.length) {

					// Find all matching slopes.
					while (end < slopes.length && Math.abs(slopes[begin].slope - slopes[end].slope) < .0000001)
						end++;

					int freq = end - begin;

					// Add in all pairs here coupled with point start.
					cnt = cnt + freq*(freq-1)/2;

					// Look for next pairs to match with this marble.
					begin = end;
				}
			}

			System.out.println(cnt);

		}
	}
}