#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
const int maxn=;
int vis[maxn],m[maxn];
int p[];
struct node{
double ans1,ans2;
int id,num;
}; bool cmp(node a,node b){
if(a.ans2!=b.ans2)
return a.ans2>b.ans2;
return a.id<b.id;
} void init(){ for(int i=;i<=;i++)
p[i]=i;
} int find(int x)
{
if(x==p[x])
return x;
else
return p[x]=find(p[x]);
} void un(int a,int b){
int x=find(a);
int y=find(b);
if(x!=y){
if(x>y)
p[x]=y;
else
p[y]=x;
}
} int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int i,j,n;
node a[];
node b[];
node mul[];
cin>>n;
init();
memset(vis,,sizeof(vis));
memset(m,,sizeof(m));
for(i=;i<n;i++)
{
int p1,p2,d,k;
cin>>a[i].id>>p1>>p2;
vis[a[i].id]=;
if(p1!=-){
un(p1,a[i].id);
vis[p1]=;
}
if(p2!=-){
un(p2,a[i].id);
vis[p2]=;
}
cin>>k;
while(k--){
cin>>d;
if(d!=-){
un(a[i].id,d);
vis[d]=;
}
}
cin>>a[i].ans1>>a[i].ans2;
}
for(i=;i<n;i++){
int id=find(a[i].id);
mul[id].id=id;
mul[id].ans1+=a[i].ans1;
mul[id].ans2+=a[i].ans2;
}
for(i=; i<; i++)
if(vis[i])
{ mul[find(i)].num++;
}
int cnt=;
for(i=;i<;i++){
if(vis[i]){
int id=find(i);
if(!m[id]){
m[id]=;
double x=double(mul[id].num);
b[cnt].ans1=mul[id].ans1*1.0/x;
b[cnt].ans2=mul[id].ans2*1.0/x;
b[cnt].id=id;
b[cnt++].num=int(x);
}
}
}
cout<<cnt<<endl;
sort(b,b+cnt,cmp);
for(i=;i<cnt;i++)
printf("%04d %d %.3lf %.3lf\n",b[i].id,b[i].num,b[i].ans1,b[i].ans2);
return ;
}