#include<bits/stdc++.h>
using namespace std;
int const INF=0x3f3f3f3f;
int const N=1e4+7;
int n,cnt;
int f[N],num[N],h[N],sr[N];
set<int>s;
struct L{
int p,num;
double h,s;
}w[N];
int find(int x){
return f[x]==x?x:f[x]=find(f[x]);
}
void merge(int a,int b){
int fx=find(a),fy=find(b);
if(fx==fy) return ;
if(fx<fy) swap(fx,fy);
f[fx]=fy;
num[fy]+=num[fx];
//cout << num[fy] << " " << num[fx] << " kkkk\n";
h[fy]+=h[fx];
sr[fy]+=sr[fx];
if(s.find(fx)!=s.end()) s.erase(fx);
s.insert(fy);
}
bool cmp(L a,L b){
return a.s ==b.s ?a.p <b.p :a.s>b.s;
}
int main(){
cin >> n;
//memset(f,-1,sizeof f);
//memset(num,1,sizeof num);
for(int i=0;i<=1e4;++i) f[i]=i,num[i]=1;
for(int i=1,a,b,c,k,z;i<=n;++i){
cin >> a >> b >> c >> k;
//s.insert(a);
if(b!=-1) merge(a,b);
if(c!=-1) merge(a,c);
for(int j=1;j<=k;++j){
cin >> z; if(z!=-1) merge(a,z);
}
if(b==-1&&c==-1&&!k) s.insert(a);
cin >> b >> c;
h[find(a)]+=b;sr[find(a)]+=c;
}
set<int>::iterator it;
for(it=s.begin();it!=s.end();++it){
w[++cnt].p =*it;int j=*it;
w[cnt].num =num[j];
//cout << j << " " << num[j] << "\n";
w[cnt].h =1.0*h[j]/num[j];
w[cnt].s =1.0*sr[j]/num[j];
}
sort(w+1,w+cnt+1,cmp);
cout << cnt << "\n";
for(int i=1;i<=cnt;++i){
printf("%04d %d %.3lf %.3lf\n",w[i].p,w[i].num,w[i].h,w[i].s);
}
return 0;
}