# Path: tryalgo/our_std.py
# def readint():
#     """
#     function to read an integer from stdin
#     """
#     return int(stdin.readline())
# 
# def readarray(typ):
#     """
#     function to read an array
#     """
#     return list(map(typ, stdin.readline().split()))


from tryalgo.our_std import readint, readarray
    not necessarily strictly)
    :param int lo:
    :param int hi: with hi >= lo
    :param float gap:
    :returns: value x in [lo,hi] maximizing f(x),
             x is computed up to some precision
    :complexity: `O(log((hi-lo)/gap))`
    """
    while hi - lo > gap:
        step = (hi - lo) / 3.
        if f(lo + step) < f(lo + 2 * step):
            lo += step
        else:
            hi -= step
    return lo


# pylint: disable=cell-var-from-loop
if __name__ == "__main__":
    def volume(level):
        """
        Computes the volume of a set of cuboids.
        """
        vol = 0
        for base, height, ground in rect:
            if base < level:
                vol += ground * min(level - base, height)
        return vol

    for test in range(readint()):

# Path: tryalgo/our_std.py
# def readint():
#     """
#     function to read an integer from stdin
#     """
#     return int(stdin.readline())
# 
# def readarray(typ):
#     """
#     function to read an array
#     """
#     return list(map(typ, stdin.readline().split()))


# Path: tryalgo/binary_search.py
from tryalgo.our_std import readint, readarray

    not necessarily strictly)
    :param int lo:
    :param int hi: with hi >= lo
    :param float gap:
    :returns: value x in [lo,hi] maximizing f(x),
             x is computed up to some precision
    :complexity: `O(log((hi-lo)/gap))`
    """
    while hi - lo > gap:
        step = (hi - lo) / 3.
        if f(lo + step) < f(lo + 2 * step):
            lo += step
        else:
            hi -= step
    return lo


# pylint: disable=cell-var-from-loop
if __name__ == "__main__":
    def volume(level):
        """
        Computes the volume of a set of cuboids.
        """
        vol = 0
        for base, height, ground in rect:
            if base < level:
                vol += ground * min(level - base, height)
        return vol

    for test in range(readint()):

        n = readint()