https://pintia.cn/problem-sets/994805046380707840/exam/problems/994805066890854400?type=7&page=1
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define oz 998244353
#define N 200010
#define INF 0x3f3f3f3f
typedef long long ll;
const int mod = 1e9 + 7;
struct aa {
int a;
double b = 0;
int c = 0;
};
vector<aa> mo(N);
bool cmp(aa a, aa b) {
if (a.b != b.b)return a.b > b.b;
if (a.c != b.c)return a.c > b.c;
return a.a < b.a;
}
void solve() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
mo[i].a = i;
}
for (int i = 1; i <= n; i++) {
int k;
cin >> k;
double sum = 0;
for (int j = 1; j <= k; j++) {
int a;
double b;
cin >> a >> b;
if (a != i) {
mo[a].b += b;
sum += b;
}
mo[a].c ++;
}
mo[i].b -= sum;
}
sort(mo.begin() + 1, mo.begin() + n + 1, cmp);
for (int i = 1; i <= n; i++) {
// cout << mo[i].a << " " << 1.0 * mo[i].b / 100 << endl;
printf("%d %.2lf\n", mo[i].a, 1.0 * mo[i].b / 100);
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
solve();
return 0;
}