// Arup Guha
// 11/30/2013
// Solution to 2013 Pacific Northwest Problem J: Janeway's Journey

import java.util.*;

public class j {

	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++) {

			// Read in all circles...
			int n = stdin.nextInt();
			circle[] circles = new circle[n];
			for (int i=0; i<n; i++) {
				double x = stdin.nextDouble();
				double y = stdin.nextDouble();
				double r = stdin.nextDouble();
				circles[i] = new circle(x,y,r);
			}

			System.out.println(solve(circles));
		}
	}

	public static int solve(circle[] circles) {

		int ans = 1, n = circles.length;

		// Try best answer for best line through each circle.
		for (int i=0; i<n; i++) {

			int cnt = 1;
			int index = 0;
			range[] ranges = new range[2*(n-1)];

			// Find range of interections (as angles on circle i) with circle j.
			for (int j=0; j<n; j++) {
				if (i == j) continue;
				range[] tmp = circles[i].getRange(circles[j]);
				ranges[index++] = tmp[0];
				ranges[index++] = tmp[1];
			}

			// Add these in and update if necessary.
			cnt += maxHit(ranges);
			if (cnt > ans)
				ans = cnt;
		}

		// This is our best.
		return ans;
	}

	// Given a set of ranges, figures out the largest number of them that are active at any one time, assuming
	// that each range is a range of angles with width <= Math.PI/2.
	public static int maxHit(range[] ranges) {

		// Find the max angle.
		double maxAngle = 0;
		for (int i=0; i<ranges.length; i++) {
			if (ranges[i].end > maxAngle)
				maxAngle = ranges[i].end;
		}

		// Only add in ranges that start before the max angle (so we don't try redundant wrap around)
		ArrayList<pair> list = new ArrayList<pair>();
		for (int i=0; i<ranges.length; i++) {
			list.add(new pair(ranges[i].start, true));
			list.add(new pair(ranges[i].end, false));
			if (ranges[i/4].start+2*Math.PI < maxAngle) {
				list.add(new pair(ranges[i].start+2*Math.PI, true));
				list.add(new pair(ranges[i].end+2*Math.PI, false));
			}
		}

		// Just do simple on off switches for ranges, like parentheses.
		Collections.sort(list);
		int cnt = 0, max = 0;
		for (int i=0; i<list.size(); i++) {

			if (list.get(i).on) cnt++;
			else cnt--;

			if (cnt > max) max = cnt;
		}

		return max;
	}
}

class circle {

	public double x;
	public double y;
	public double r;

	public circle(double myx, double myy, double myr) {
		x = myx;
		y = myy;
		r = myr;
	}

	public range[] getRange(circle other) {

		double D = distance(other);
		double offset1 = Math.asin(Math.abs(r-other.r)/D);
		double offset2 = Math.asin((r+other.r)/D);

		// Get base angle from 0 to 2PI.
		double baseAngle = Math.atan2(other.y-y, other.x-x);
		if (baseAngle < 0) baseAngle += 2*Math.PI;

		// Set up startAngle (non-criss cross case)
		double angle1[] = new double[2];
		double angle2[] = new double[2];
		if (this.r <= other.r) {
			angle1[0] = baseAngle - offset1 - Math.PI/2;
			angle2[0] = baseAngle + offset1 + Math.PI/2;
		}
		else {
			angle1[0] = baseAngle - Math.PI/2 + offset1;
			angle2[0] = baseAngle + Math.PI/2 - offset1;
		}

		// endAngle is criss-cross case.
		angle1[1] = baseAngle - Math.PI/2 + offset2;
		angle2[1] = baseAngle + Math.PI/2 - offset2;

		fix(angle1);
		fix(angle2);

		// Finally, return!
		range[] ans = new range[2];
		ans[0] = new range(angle1[0], angle1[1]);
		ans[1] = new range(angle2[0], angle2[1]);
		return ans;
	}

	public static void fix(double[] rangeList) {

		// Map if necessary.
		if (rangeList[0] < 0) rangeList[0] += 2*Math.PI;
		if (rangeList[1] < 0) rangeList[1] += 2*Math.PI;

		// Set up a default start and end of the range.
		double start = Math.min(rangeList[0], rangeList[1]);
		double end = Math.max(rangeList[0], rangeList[1]);

		// Swap if in wrong order.
		if (end - start > Math.PI) {
			 double temp = end;
			 end = start;
			 start = temp;
		}
		if (end < start) end += 2*Math.PI;

		rangeList[0] = start;
		rangeList[1] = end;
	}

	public double distance(circle other) {
		return Math.sqrt(Math.pow(x-other.x, 2) + Math.pow(y-other.y, 2));
	}
}

class range {

	public double start;
	public double end;

	public range(double s, double e) {
		start = s;
		end = e;
	}
}

class pair implements Comparable<pair> {

	public double x;
	public boolean on;

	public pair(double val, boolean start) {
		x = val;
		on = start;
	}

	public int compareTo(pair other) {
		if (x < other.x) return -1;
		if (x > other.x) return 1;
		if (this.on && !other.on) return -1;
		if (!this.on && other.on) return 1;
		return 0;
	}

}