#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct node0 {
int id, fid, mid, num, area;
int cid[10];
}data[1001];
struct node {
int id, people;
double num, area;
bool flag = false;
}ans[10000];
vector<int> father(10000);
vector<bool> visited(10000);
int find(int x){
while (x != father[x])
x = father[x];
return x;
}
void Union(int a, int b){
a = find(a);
b = find(b);
if(a > b) father[a] = b;
else father[b] = a;
}
bool cmp(node &a, node &b){
if(a.area == b.area) return a.id < b.id;
else return a.area > b.area;
}
int main(){
int n, k, cnt = 0;
cin >> n;
for (int i = 0; i < 10000; i++)
father[i] = i;
for (int i = 0; i < n; i++) {
cin >> data[i].id >> data[i].fid >> data[i].mid >> k;
visited[data[i].id] = true;
if (data[i].fid != -1) {
visited[data[i].fid] = true;
Union(data[i].fid, data[i].id);
}
if (data[i].mid != -1) {
visited[data[i].mid] = true;
Union(data[i].mid, data[i].id);
}
for (int j = 0; j < k; j++) {
cin >> data[i].cid[j];
visited[data[i].cid[j]] = true;
Union(data[i].cid[j], data[i].id);
}
cin >> data[i].num >> data[i].area;
}
for (int i = 0; i < n; i++) {
int id = find(data[i].id);
ans[id].id = id;
ans[id].num += data[i].num;
ans[id].area += data[i].area;
ans[id].flag = true;
}
for (int i = 0; i < 10000; i++) {
if(visited[i]) ans[find(i)].people++;
if(ans[i].flag) cnt++;
}
for (int i = 0; i < 10000; i++) {
if(ans[i].flag){
ans[i].num = ans[i].num * 1.0 / ans[i].people;
ans[i].area = ans[i].area * 1.0 / ans[i].people;
}
}
sort(ans, ans + 10000, cmp);
cout << cnt << endl;
for (int i = 0; i < cnt; i++) {
printf("%04d %d %.3lf %.3lf\n", ans[i].id, ans[i].people, ans[i].num, ans[i].area);
}
return 0;
}