#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double event[1000000];
double x[200];
double y[200];
double z[200];
double r[200];
double dist(double x1,double y1,double z1,double x2,double y2,double z2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
}
double Abs(double a){return max(a,-a);}
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1);
int sig(double r){return (r<-EPS)?-1:(r>+EPS)?+1:0;}
struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y):x(x),y(y){}
	Pt operator+(const Pt &a)const{return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt &a)const{return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt &a)const{return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator-()const{return Pt(-x,-y);}
	Pt operator*(const double &k)const{return Pt(x*k,y*k);}
	Pt operator/(const double &k)const{return Pt(x/k,y/k);}
	double Abs()const{return sqrt(x*x+y*y);}
	double Abs2()const{return x*x+y*y;}
	double arg()const{return atan2(y,x);}
	double dot(const Pt &a)const{return x*a.x+y*a.y;}
	double det(const Pt &a)const{return x*a.y-y*a.x;}
};
double tri(const Pt&a,const Pt&b,const Pt&c){return (b-a).det(c-a);}
pair<Pt,Pt> pCC(Pt a,double r,Pt b,double s){
	double d=(b-a).Abs();
	double x=(d*d+r*r-s*s)/(d*2);
	Pt e=(b-a)/d,w=e*Pt(0,1)*sqrt(max(r*r-x*x,0.0));
	return make_pair(a+e*x-w,a+e*x+w);
}
int ans[100000];
int UF[128];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%lf%lf%lf%lf",x+i,y+i,z+i,r+i);
		int ind=0;
		event[ind++]=0;
		for(int i=0;i<a;i++){
			event[ind++]=z[i]-r[i];
			event[ind++]=z[i]+r[i];
		}
		for(int i=0;i<a;i++)
			for(int j=i+1;j<a;j++){
				if(dist(x[i],y[i],z[i],x[j],y[j],z[j])>r[i]+r[j])continue;
				if(Abs(r[i]-r[j])>dist(x[i],y[i],z[i],x[j],y[j],z[j]))continue;
				pair<Pt,Pt> inter=pCC(Pt(0.0,z[i]),r[i],Pt(dist(x[i],y[i],0,x[j],y[j],0),z[j]),r[j]);
				event[ind++]=inter.first.y;
				event[ind++]=inter.second.y;
			}
		event[ind++]=50000;
		std::sort(event,event+ind);
		int at=0;
		int last=0;
		for(int i=0;i<ind;i++){
			if(i&&event[i]-event[i-1]<EPS)continue;
			double M=(event[i]+event[i-1])/2;
			for(int j=0;j<a;j++)UF[j]=-1;
			for(int j=0;j<a;j++){
				if(M+EPS<z[j]-r[j]||M-EPS>z[j]+r[j])continue;
				for(int k=j+1;k<a;k++){
					if(M+EPS<z[k]-r[k]||M-EPS>z[k]+r[k])continue;
					if(dist(x[j],y[j],0,x[k],y[k],0)<sqrt(r[j]*r[j]-(z[j]-M)*(z[j]-M))+sqrt(r[k]*r[k]-(z[k]-M)*(z[k]-M)))UNION(j,k);
				}
			}
			int count=0;
			for(int j=0;j<a;j++){
				if(M+EPS<z[j]-r[j]||M-EPS>z[j]+r[j])continue;
				//printf("(%d,%d) ",j,UF[j]);
				if(UF[j]<0)count++;
			}
			if(last!=count){
				if(last<count)ans[at++]=1;
				else ans[at++]=0;
			}
		//	printf("%f %d\n",M,count);
			last=count;
		}
		printf("%d\n",at);
		for(int i=0;i<at;i++)printf("%d",ans[i]);
		printf("\n");
	}
}