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, heappushpop



def main():

    INF = 10 ** 18



    sum_B = 0

    L, R = [INF], [INF]

    sum_L = sum_R = 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



            if len(L) > len(R):

                l = -L[0]

                if a >= l:

                    heappush(R, a)

                    sum_R += a

                else:

                    heappushpop(L, -a)

                    sum_L += a - l

                    heappush(R, l)

                    sum_R += l

            elif len(L) == 0:

                heappush(R, a)

                sum_L += a

            else:

                r = R[0]

                if a <= r:

                    heappush(L, -a)

                    sum_L += a

                else:

                    heappushpop(R, a)

                    sum_R += a - r

                    heappush(L, -r)

                    sum_L += r



        else:

            median = -L[0]

            res = (median * len(L) - sum_L) + (sum_R - median * len(R)) + sum_B

            print((median, res))



if __name__ == '__main__':

    main()

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, heappushpop


def main():
    INF = 10**18
    sum_B = 0
    L, R = [INF], [INF]
    sum_L = sum_R = 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
            if len(L) > len(R):
                l = -L[0]
                if a >= l:
                    heappush(R, a)
                    sum_R += a
                else:
                    heappushpop(L, -a)
                    sum_L += a - l
                    heappush(R, l)
                    sum_R += l
            elif len(L) == 0:
                heappush(R, a)
                sum_L += a
            else:
                r = R[0]
                if a <= r:
                    heappush(L, -a)
                    sum_L += a
                else:
                    heappushpop(R, a)
                    sum_R += a - r
                    heappush(L, -r)
                    sum_L += r
        else:
            median = -L[0]
            res = (median * len(L) - sum_L) + (sum_R - median * len(R)) + sum_B
            print((median, res))


if __name__ == "__main__":
    main()

-from heapq import heappush, heappop +from heapq import heappush, heappushpop -    L_size = R_size = 0 -            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 +            if len(L) > len(R): +                l = -L[0] +                if a >= l: +                    heappush(R, a) +                    sum_R += a +                else: +                    heappushpop(L, -a) +                    sum_L += a - l +                    heappush(R, l) +                    sum_R += l +            elif len(L) == 0: +                heappush(R, a) +                sum_L += a -                heappush(R, m) -                R_size += 1 -                sum_R += m +                r = R[0] +                if a <= r: +                    heappush(L, -a) +                    sum_L += a +                else: +                    heappushpop(R, a) +                    sum_R += a - r +                    heappush(L, -r) +                    sum_L += r -            min_value = sum_B + sum_R - sum_L -            if L_size != R_size: -                min_value += median -            print((median, min_value)) +            res = (median * len(L) - sum_L) + (sum_R - median * len(R)) + sum_B +            print((median, res))