#include <stdio.h>
#include <math.h>
#include <string.h>

int n;
int circle[24][4];
char bitDP[(1<<24)]; // ??????????????????bit??§??????
int overlap[24]; // ?????????????????????bit??§??????

int main()
{
	int i, j, bit;
	int next, ans;
	
	while(scanf("%d",&n) != EOF) {
		if(n == 0) {
			break;
		}
		
		for(i = 0; i < n; i++) {
			scanf("%d",&circle[i][0]);
			scanf("%d",&circle[i][1]);
			scanf("%d",&circle[i][2]);
			scanf("%d",&circle[i][3]);
			
			overlap[i] = 0;
			for(j = 0; j < i; j++) {
				int distance_x = circle[i][0] - circle[j][0];
				int distance_y = circle[i][1] - circle[j][1];
				double distance_circle = sqrt(pow(distance_x, 2) + pow(distance_y, 2));
				if(circle[i][2] + circle[j][2] > distance_circle) {
					overlap[i] += (1 << j);
				}
			}
		}
		
		memset(bitDP, -1, sizeof(bitDP));
		bitDP[0] = 0;
		
		ans = 0;
		for(bit = 0; bit < (1 << n); bit++) {
			if(bitDP[bit] == -1) {
				continue;
			}
			if(ans < bitDP[next]) {
				ans = bitDP[next];
			}
			
			for(i = 0; i < n; i++) {
				if(((1 << i) & bit) || !((overlap[i] & bit) == overlap[i])) {
					continue;
				}
				
				for(j = i+1; j < n; j++) {
					if(((1 << i) | (1 << j)) & bit) {
						continue;
					}
					if(!((overlap[j] & bit) == overlap[j])) {
						continue;
					}
					if(circle[i][3] != circle[j][3]) {
						continue;
					}
					
					next = (((1 << i) | (1 << j)) | bit);
					if(bitDP[next] < bitDP[bit] + 2) {
						bitDP[next] = bitDP[bit] + 2;
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	
	return 0;
}