// Arup Guha
// 4/18/2014
// Solution to COP 4516 Final Team Contest Problem: Asteroids
// Note: This works for input with collinear points, but the problem disallows it.

import java.util.*;

public class asteroids {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=0; loop<numCases; loop++) {
			int n = stdin.nextInt();
			vect[] asteroids = new vect[n];
			for (int i=0; i<n; i++) {
				int x = stdin.nextInt();
				int y = stdin.nextInt();
				int z = stdin.nextInt();
				asteroids[i] = new vect(x,y,z);
			}
			System.out.println(solve(asteroids));
		}
	}

	public static int solve(vect[] pts) {

		int n = pts.length;
		int best = Math.min(3, n);
		boolean entered = false;

		// Choose 3 code can be written as a triple for loop.
		for (int i=0; i<n; i++) {
			for (int j=i+1; j<n; j++) {
				for (int k=j+1; k<n; k++) {

					// Get two vectors on this plane.
					vect v1 = new vect(pts[j].x-pts[i].x, pts[j].y-pts[i].y, pts[j].z-pts[i].z);
					vect v2 = new vect(pts[k].x-pts[i].x, pts[k].y-pts[i].y, pts[k].z-pts[i].z);

					// Skip collinear points.
					if (v1.cross(v2).magsq() == 0) {
						System.out.println("ERROR COLLINEAR POINTS");
						continue;
					}
					entered = true;

					// Here is our plane equation.
					vect eqn = v1.cross(v2);
					long d = eqn.dot(pts[i]);

					// Count how many of the future points are on this plane.
					int cnt = 0;
					for (int a=0; a<n; a++)
						if (eqn.dot(pts[a]) == d)
							cnt++;

					// Update if necessary.
					if (cnt > best) best = cnt;
				}
			}
		}

		// All points on a line.
		if (!entered) return n;

		// Normal case.
		return best;
	}
}

class vect {

	public long x;
	public long y;
	public long z;

	public vect(long myx, long myy, long myz) {
		x = myx;
		y = myy;
		z = myz;
	}

	public vect cross(vect other) {
		return new vect(y*other.z-z*other.y, z*other.x-x*other.z, x*other.y-y*other.x);
	}

	public long magsq() {
		return x*x + y*y + z*z;
	}

	public long dot(vect other) {
		return x*other.x + y*other.y + z*other.z;
	}
}