#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>

using namespace std;

int par[123];
int x[123],y[123],z[123],r[123];

int find(int x){
  return (par[x]==x)?x:par[x]=find(par[x]);
}

void unite(int a,int b){
  par[find(a)]=find(b);
}

double sqr(double d){
  return d*d;
}

double dist(int i,int j,double zz){
  return sqrt(r[i]*r[i]-sqr(z[i]-zz))+sqrt(r[j]*r[j]-sqr(z[j]-zz));
}

double cross(int i,int j,double bm){
  double d=dist(i,j,bm);
  return sqr(x[i]-x[j])+sqr(y[i]-y[j])-d*d<0;
}

int main(){
  for(int n;cin>>n,n;){
    vector<double> cz{0,1e9};
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>z[i]>>r[i];
      cz.push_back(z[i]+r[i]);
      cz.push_back(z[i]-r[i]);
      for(int j=0;j<i;j++){
	if(sqr(x[i]-x[j])+sqr(y[i]-y[j])+sqr(z[i]-z[j])<sqr(r[i]+r[j])){
	  int rl=max(z[i]-r[i],z[j]-r[j]),rh=min(z[i]+r[i],z[j]+r[j]);
	  double l=rl,h=rh;
	  for(int k=0;k<99;k++){
	    double lh=(h-l)/3+l,hl=(h-l)*2/3+l;
	    if(dist(i,j,lh)<dist(i,j,hl)){
	      l=lh;
	    }else{
	      h=hl;
	    }
	  }
	  double bl=rl,bh=l;
	  double tl=l,th=rh;
	  for(int k=0;k<99;k++){
	    double bm=(bh+bl)/2;
	    if(cross(i,j,bm)){
	      bh=bm;
	    }else{
	      bl=bm;
	    }
	    double tm=(tl+th)/2;
	    if(cross(i,j,tm)){
	      tl=tm;
	    }else{
	      th=tm;
	    }
	  }
	  //	  cout<<rl<<' '<<l<<' '<<rh<<' '<<bl<<' '<<tl<<endl;
	  cz.push_back(bl);
	  cz.push_back(tl);
	}
      }
    }
    sort(begin(cz),end(cz));
    vector<int> ns{0};
    for(int i=0;i<cz.size()-1;i++){
      double m=(cz[i]+cz[i+1])/2;
      iota(begin(par),end(par),0);
      for(int i=0;i<n;i++){
	if(r[i]*r[i]>sqr(z[i]-m)){
	  for(int j=0;j<i;j++){
	    if(r[j]*r[j]>sqr(z[j]-m)&&cross(i,j,m)){
	      unite(i,j);
	    }
	  }
	}else{
	  par[i]=-1;
	}
      }
      bool u[123]={};
      int ncs=0;
      for(int i=0;i<n;i++){
	if(par[i]>=0){
	  ncs+=!u[find(i)]++;
	}
      }
      //      cout<<m<<' '<<ncs<<endl;
      if(ncs!=ns.back()){
	ns.push_back(ncs);
      }
    }
    cout<<ns.size()-1<<endl;
    for(int i=0;i<ns.size()-1;i++){
      cout<<(ns[i+1]-ns[i]==1);
    }
    cout<<endl;
  }
}