#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

pair<double, double>cross(tuple<double,double,double,double> a,tuple<double,double,double,double> b){
	double dx=sqrt((get<0>(a)-get<0>(b))*(get<0>(a)-get<0>(b))+(get<1>(a)-get<1>(b))*(get<1>(a)-get<1>(b)));
	double dy=(get<2>(b)-get<2>(a));
	double di=sqrt(dx*dx+dy*dy);
	double ar=get<3>(a),br=get<3>(b);
	if(ar+br<di){return mp(-1.0,-1.0);}
	double ue,st;
		 if(dx*dx+(dy-br)*(dy-br)<ar*ar){ue=get<2>(b)-br;}
	else if(dx*dx+(-dy-ar)*(-dy-ar)<br*br){ue=get<2>(a)-ar;}
	else{
		
		double costh=(ar*ar+di*di-br*br)/(2*ar*di);
		if(abs(costh)>1){cerr<<"de"<<costh<<endl;}
		double sinth=-sqrt(1-costh*costh);
		double ny=(dy*costh+dx*sinth)*ar/di;
		ue=get<2>(a)+ny;
	}
	
		 if(dx*dx+(dy+br)*(dy+br)<ar*ar){st=get<2>(b)+br;}
	else if(dx*dx+(-dy+ar)*(-dy+ar)<br*br){st=get<2>(a)+ar;}
	else{
		
		double costh=(ar*ar+di*di-br*br)/(2*ar*di);
		if(abs(costh)>1){cerr<<"de"<<costh<<endl;}
		double sinth=sqrt(1-costh*costh);
		double ny=(dy*costh+dx*sinth)*ar/di;
		st=get<2>(a)+ny;
	}
	return mp(ue,st);
}
bool solve(void){
	int i,n,j;cin>>n;
	if(n==0){return false;}
	vector<tuple<double,double,double,double>>ball(n);
	for(i=0;i<n;i++){
		double x,y,z,r;cin>>x>>y>>z>>r;
		ball[i]=mt(x,y,z,r);
	}
	vector<tuple<double,int,int,int>>ivent;
	ivent.reserve(n*(n+1)+1);
	for(i=0;i<n;i++){
		ivent.pub(mt(get<2>(ball[i])-get<3>(ball[i]),i,0,3));
		ivent.pub(mt(get<2>(ball[i])+get<3>(ball[i]),i,0,2));
		for(j=i+1;j<n;j++){
			auto ret=cross(ball[i],ball[j]);
			if(ret.fir<0){continue;}
			ivent.pub(mt(ret.fir,i,j,1));
			ivent.pub(mt(ret.sec,i,j,0));
		}
	}
	ivent.pub(mt(2.19e15,0,0,999));
	SO(ivent);
	double mae=-big;
	int maeans=0;
	vector<bool>act(n);
	vector<vector<int>>ren(n);
	string str;
	for(auto it:ivent){
		double t,a,b,syu;tie(t,a,b,syu)=it;
		
		if(abs(mae-t)>eps){
			int ans=0;
			vector<bool>kta(n);
			for(i=0;i<n;i++){
				if(!act[i]){continue;}
				if(kta[i]){continue;}
				queue<int>que;
				kta[i]=1;que.push(i);
				ans++;
				while(que.size()){
					int gen=que.front();
					que.pop();
					for(auto jt:ren[gen]){
						if(!kta[jt]){kta[jt]=1;que.push(jt);}
					}
				}
			}
			//cerr<<maeans<<' '<<ans<<endl;
			if(maeans>ans){str.pub('0');}
			if(maeans<ans){str.pub('1');}
			maeans=ans;
		}
		//cerr<<t<<' '<<a<<' '<<b<<' '<<syu<<endl;
		
		if(syu==2){act[a]=0;}
		if(syu==3){act[a]=1;}
		if(syu==0){
			for(int j=0;j<ren[a].size();j++){
				if(ren[a][j]==b){ren[a][j]=ren[a].back();ren[a].pob();break;}
			}
			for(int j=0;j<ren[b].size();j++){
				if(ren[b][j]==a){ren[b][j]=ren[b].back();ren[b].pob();break;}
			}
		}
		if(syu==1){ren[a].pub(b);ren[b].pub(a);}
		
		mae=t;
	}
	cout<<str.size()<<endl;
	cout<<str<<endl;
	return true;
}
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3280