#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,p,x;
struct person{
int num,ans,ot,ac,cnt;
}a[10005];
bool cmp(const person &e,const person &r)
{
if(e.ac==r.ac)
{
if(e.cnt==r.cnt)
return e.num<r.num;
return e.cnt>r.cnt;
}
return e.ac>r.ac;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>k;
a[i].num=i;
for(int j=1;j<=k;j++)
{
cin>>p>>x;
a[p].ans+=x;
a[p].cnt++;
a[i].ot+=x;
}
}
for(int i=1;i<=n;i++)
a[i].ac=a[i].ans-a[i].ot;
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++)
printf("%d %.2lf\n",a[i].num,(double)a[i].ac/100);
return 0;
}