from heapq import heappush, heappop



INF = 10 ** 18



sum_B = 0

L, R = [INF], [INF]

sum_L = sum_R = 0

L_size = R_size = 0



A = list(map(int, open(0).read().split()))



Q = next(A)

for _ in range(Q):

    q = next(A)

    if q == 1:

        a, b = next(A), next(A)



        sum_B += b



        max_L = -heappop(L)

        min_R = heappop(R)



        sum_L -= max_L

        sum_R -= min_R



        l, m, r = sorted((max_L, a, min_R))



        heappush(L, -l)

        heappush(R, r)

        sum_L += l

        sum_R += r



        if L_size == R_size:

            heappush(L, -m)

            L_size += 1

            sum_L += m

        else:

            heappush(R, m)

            R_size += 1

            sum_R += m



    else:

        median = -L[0]

        min_value = sum_B + sum_R - sum_L

        if L_size != R_size:

            min_value += median

        print((median, min_value))

from heapq import heappush, heappop



def main():

    INF = 10 ** 18



    sum_B = 0

    L, R = [INF], [INF]

    sum_L = sum_R = 0

    L_size = R_size = 0



    A = list(map(int, open(0).read().split()))



    Q = next(A)

    for _ in range(Q):

        q = next(A)

        if q == 1:

            a, b = next(A), next(A)



            sum_B += b



            max_L = -heappop(L)

            min_R = heappop(R)



            sum_L -= max_L

            sum_R -= min_R



            l, m, r = sorted((max_L, a, min_R))



            heappush(L, -l)

            heappush(R, r)

            sum_L += l

            sum_R += r



            if L_size == R_size:

                heappush(L, -m)

                L_size += 1

                sum_L += m

            else:

                heappush(R, m)

                R_size += 1

                sum_R += m



        else:

            median = -L[0]

            min_value = sum_B + sum_R - sum_L

            if L_size != R_size:

                min_value += median

            print((median, min_value))





if __name__ == '__main__':

    main()

from heapq import heappush, heappop

INF = 10**18
sum_B = 0
L, R = [INF], [INF]
sum_L = sum_R = 0
L_size = R_size = 0
A = list(map(int, open(0).read().split()))
Q = next(A)
for _ in range(Q):
    q = next(A)
    if q == 1:
        a, b = next(A), next(A)
        sum_B += b
        max_L = -heappop(L)
        min_R = heappop(R)
        sum_L -= max_L
        sum_R -= min_R
        l, m, r = sorted((max_L, a, min_R))
        heappush(L, -l)
        heappush(R, r)
        sum_L += l
        sum_R += r
        if L_size == R_size:
            heappush(L, -m)
            L_size += 1
            sum_L += m
        else:
            heappush(R, m)
            R_size += 1
            sum_R += m
    else:
        median = -L[0]
        min_value = sum_B + sum_R - sum_L
        if L_size != R_size:
            min_value += median
        print((median, min_value))

from heapq import heappush, heappop


def main():
    INF = 10**18
    sum_B = 0
    L, R = [INF], [INF]
    sum_L = sum_R = 0
    L_size = R_size = 0
    A = list(map(int, open(0).read().split()))
    Q = next(A)
    for _ in range(Q):
        q = next(A)
        if q == 1:
            a, b = next(A), next(A)
            sum_B += b
            max_L = -heappop(L)
            min_R = heappop(R)
            sum_L -= max_L
            sum_R -= min_R
            l, m, r = sorted((max_L, a, min_R))
            heappush(L, -l)
            heappush(R, r)
            sum_L += l
            sum_R += r
            if L_size == R_size:
                heappush(L, -m)
                L_size += 1
                sum_L += m
            else:
                heappush(R, m)
                R_size += 1
                sum_R += m
        else:
            median = -L[0]
            min_value = sum_B + sum_R - sum_L
            if L_size != R_size:
                min_value += median
            print((median, min_value))


if __name__ == "__main__":
    main()

-INF = 10**18 -sum_B = 0 -L, R = [INF], [INF] -sum_L = sum_R = 0 -L_size = R_size = 0 -A = list(map(int, open(0).read().split())) -Q = next(A) -for _ in range(Q): -    q = next(A) -    if q == 1: -        a, b = next(A), next(A) -        sum_B += b -        max_L = -heappop(L) -        min_R = heappop(R) -        sum_L -= max_L -        sum_R -= min_R -        l, m, r = sorted((max_L, a, min_R)) -        heappush(L, -l) -        heappush(R, r) -        sum_L += l -        sum_R += r -        if L_size == R_size: -            heappush(L, -m) -            L_size += 1 -            sum_L += m + +def main(): +    INF = 10**18 +    sum_B = 0 +    L, R = [INF], [INF] +    sum_L = sum_R = 0 +    L_size = R_size = 0 +    A = list(map(int, open(0).read().split())) +    Q = next(A) +    for _ in range(Q): +        q = next(A) +        if q == 1: +            a, b = next(A), next(A) +            sum_B += b +            max_L = -heappop(L) +            min_R = heappop(R) +            sum_L -= max_L +            sum_R -= min_R +            l, m, r = sorted((max_L, a, min_R)) +            heappush(L, -l) +            heappush(R, r) +            sum_L += l +            sum_R += r +            if L_size == R_size: +                heappush(L, -m) +                L_size += 1 +                sum_L += m +            else: +                heappush(R, m) +                R_size += 1 +                sum_R += m -            heappush(R, m) -            R_size += 1 -            sum_R += m -    else: -        median = -L[0] -        min_value = sum_B + sum_R - sum_L -        if L_size != R_size: -            min_value += median -        print((median, min_value)) +            median = -L[0] +            min_value = sum_B + sum_R - sum_L +            if L_size != R_size: +                min_value += median +            print((median, min_value)) + + +if __name__ == "__main__": +    main()