#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<ctime>
#include<cstring>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<stack>
#include<deque>
#include<list>
#include<vector>
#define LL long long
/*
#ifdef unix
#define INT64 "%lld"
#else
#define INT64 "%I64d"
#endif
*/
using namespace std;
int n,m,cnt,snt,K,times;
LL oo=1000000007;
struct dic
{
	int x,y,r;
	int c;
}p[110];
int num[110];
int ans;
bool vis[110];
bool f[16777216];
int dis(int x1,int y1,int x2,int y2)
{
	return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
bool cover(int pos,int state)
{
	for (int i=1;i<pos;i++)
	if (((state>>(i-1))&1)&&dis(p[i].x,p[i].y,p[pos].x,p[pos].y)<(p[i].r+p[pos].r)*(p[i].r+p[pos].r)) 
	return true;
	return false;
}
void dp(int state)
{
	int sum=0;
	for (int i=0;i<n;i++) if ((state>>i)&1) sum++;
	ans=max(ans,n-sum);
	if (f[state]) return;
	f[state]=true;
	for (int i=1;i<=n;i++)
	if (((state>>(i-1))&1)&&!cover(i,state))
	for (int j=i+1;j<=n;j++)
	if (((state>>(j-1))&1)&&p[i].c==p[j].c&&!cover(j,state))
	{
		int tstate=state^(1<<(i-1))^(1<<(j-1));
		dp(tstate);
	}
}
void work()
{
	memset(p,0,sizeof(p));
	for (int i=1;i<=n;i++)
	scanf("%d%d%d%d",&p[i].x,&p[i].y,&p[i].r,&p[i].c);
	ans=0;
	memset(f,0,sizeof(f));
	dp((1<<n)-1);
	printf("%d\n",ans);
}
int main()
{
	scanf("%d",&n);
	while (n!=0)
	{
		work();
		scanf("%d",&n);
	}
    return 0;
}