// File: /workspace/github_cpp_makefile_star2_O3/hcoona[P]POJ-Solutions/P1018.cpp
// Function: POJ::P1018::Run(std::istream&, std::ostream&)
void P1018::Run(istream &in, ostream &out)
    {
        const int NMax = 100;
        const int MMax = 100;
        vector<vector<pair<int, int> > > deviceData(NMax, vector<pair<int, int> >(MMax));

        int t;
        in >> t;
        while (t--) {
            int n;
            in >> n;

            for (int nidx = 0; nidx < n; nidx++) {
                int m;
                in >> m;
                for (int midx = 0; midx < m; midx++) {
                    int b, p;
                    in >> b >> p;
                    deviceData[nidx][midx] = make_pair(b, p);
                }
                sort(
                    deviceData[nidx].begin(),
                    deviceData[nidx].end(),
                    PredByFirstGt<int, int>);
            }

            out << setprecision(3) << fixed << Solve(deviceData) << endl;
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, %r14
movl $0x320, %edi            # imm = 0x320
callq 0x1100
leaq 0x18(%rsp), %rbx
movq %rax, (%rbx)
movq %rax, %r15
addq $0x320, %r15            # imm = 0x320
movl $0x320, %edx            # imm = 0x320
movq %rax, %rdi
xorl %esi, %esi
callq 0x1090
movq %r15, 0x10(%rbx)
movq %r15, 0x8(%rbx)
leaq 0x30(%rsp), %rdi
movq %rsp, %rcx
movl $0x64, %esi
movq %rbx, %rdx
callq 0x170e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1351
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x1110
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x10a0
subl $0x1, 0x18(%rsp)
jb 0x14b4
leaq 0xc(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq %r14, %rdi
movq %rsp, %rsi
callq 0x10a0
cmpl $0x0, (%rsp)
jle 0x1440
xorl %r15d, %r15d
movq %r14, %rdi
leaq 0x4(%rsp), %rsi
callq 0x10a0
cmpl $0x0, 0x4(%rsp)
leaq (%r15,%r15,2), %r12
jle 0x13e2
xorl %ebx, %ebx
movq %r14, %rdi
movq %r13, %rsi
callq 0x10a0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x10a0
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %edx
movq 0x30(%rsp), %rax
movq (%rax,%r12,8), %rsi
movl %ecx, (%rsi,%rbx,8)
movl %edx, 0x4(%rsi,%rbx,8)
incq %rbx
movslq 0x4(%rsp), %rcx
cmpq %rcx, %rbx
jl 0x13a5
jmp 0x13e7
movq 0x30(%rsp), %rax
movq (%rax,%r12,8), %rbx
movq 0x8(%rax,%r12,8), %r12
cmpq %r12, %rbx
je 0x1430
movq %r12, %rax
subq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r12, %rsi
leaq 0xf0(%rip), %rcx        # 0x1509
callq 0x1a25
movq %rbx, %rdi
movq %r12, %rsi
leaq 0xde(%rip), %rdx        # 0x1509
callq 0x1b5c
incq %r15
movslq (%rsp), %rax
cmpq %rax, %r15
jl 0x138b
movq 0x10(%rsp), %rdx
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x3, 0x8(%rdx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rdx,%rax), %ecx
movl $0xfffffefb, %esi       # imm = 0xFFFFFEFB
andl %esi, %ecx
orl $0x4, %ecx
movl %ecx, 0x18(%rdx,%rax)
leaq 0x30(%rsp), %rsi
callq 0x1512
movq 0x10(%rsp), %rdi
callq 0x1150
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10b0
subl $0x1, 0x18(%rsp)
jae 0x1373
leaq 0x30(%rsp), %rdi
callq 0x17a6
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14f4
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1501
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x1110
jmp 0x1501
movq %rax, %rbx
jmp 0x1501
jmp 0x14f4
jmp 0x14f4
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x17a6
movq %rbx, %rdi
callq 0x1170