#include<bits/stdc++.h>
using namespace std;
const int maxn=10010;
int p[maxn]={0},vis[maxn]={0};
struct Data{
int id,fa,ma,tao,area;
int kid[10];
}data[1005];
struct node{
int id,people;
double tao,area;
}ans[10005];
bool cmp(node a,node b){
if(a.area!=b.area)return a.area>b.area;
else return a.id<b.id;
}
int find(int x){
while(x!=p[x])
x=p[x];
return x;
}
void Union(int a,int b){
int fa=find(a);
int fb=find(b);
if(fa>fb)
p[fa]=fb;
else if(fa<fb)
p[fb]=fa;
}
int main(){
int n,k,cnt=0;
cin>>n;
for(int i=0;i<10005;i++){
p[i]=i;
}
for(int i=0;i<n;i++){
scanf("%d %d %d %d",&data[i].id,&data[i].fa,&data[i].ma,&k);
vis[data[i].id]=1;
if(data[i].fa!=-1){
Union(data[i].id,data[i].fa);
vis[data[i].fa]=1;
}
if(data[i].ma!=-1){
Union(data[i].id,data[i].ma);
vis[data[i].ma]=1;
}
for(int j=0;j<k;j++){
scanf("%d",&data[i].kid[j]);
Union(data[i].id,data[i].kid[j]);
vis[data[i].kid[j]]=1;
}
cin>>data[i].tao>>data[i].area;
}
for(int i=0;i<n;i++){
int id=find(data[i].id);
ans[id].id=id;
ans[id].tao+=data[i].tao;
ans[id].area+=data[i].area;
}
for(int i=0;i<10005;i++){
if(vis[i])
ans[find(i)].people++;
if(ans[i].area)
cnt++;
}
for(int i=0;i<10005;i++){
if(ans[i].tao){
ans[i].area=(ans[i].area*1.0/ans[i].people);
ans[i].tao=(ans[i].tao*1.0/ans[i].people);
}
}
sort(ans,ans+10000,cmp);
printf("%d\n",cnt);
for(int i=0;i<cnt;i++){
printf("%04d %d %.3lf %.3lf\n",ans[i].id,ans[i].people,ans[i].tao,ans[i].area);
}
return 0;
}