from heapq import heapify, heappush, heappop

import sys

input = sys.stdin.readline



Q = int(eval(input()))

ss = eval(input())

t, A, B = list(map(int, ss.split()))

PQ1, PQ2 = [-A], [A]

fr = to = A

minF = 0

accB = B

anss = []

for _ in range(Q-1):

    ss = eval(input())

    if ss[0] == '1':

        t, A, B = list(map(int, ss.split()))

        if fr <= A <= to:

            heappush(PQ1, -A)

            heappush(PQ2, A)

        elif A < fr:

            p = -heappop(PQ1)

            heappush(PQ2, p)

            heappush(PQ1, -A)

            heappush(PQ1, -A)

            minF += fr-A

        else:

            p = heappop(PQ2)

            heappush(PQ1, -p)

            heappush(PQ2, A)

            heappush(PQ2, A)

            minF += A-to

        fr = -heappop(PQ1)

        to = heappop(PQ2)

        heappush(PQ1, -fr)

        heappush(PQ2, to)

        accB += B

    else:

        anss.append((fr, minF+accB))



print(('\n'.join([str(x[0])+' '+str(x[1]) for x in anss])))

from heapq import heapify, heappush, heappop

import sys

input = sys.stdin.readline



Q = int(eval(input()))

querys = [tuple(map(int, input().split())) for _ in range(Q)]



anss = []

PQL, PQR = [], []

sumL = sumR = 0

numL = numR = 0

sumB = 0

for query in querys:

    if query[0] == 1:  # 更新

        a, b = query[1:]

        sumB += b

        if numL == 0:

            heappush(PQL, -a)

            sumL += a

            numL += 1

        elif numL == numR:

            if a <= -PQL[0]:

                heappush(PQL, -a)

                sumL += a

                numL += 1

            else:

                heappush(PQR, a)

                c = heappop(PQR)

                sumR += a-c

                heappush(PQL, -c)

                sumL += c

                numL += 1

        else:

            if a < -PQL[0]:

                heappush(PQL, -a)

                c = -heappop(PQL)

                sumL += a-c

                heappush(PQR, c)

                sumR += c

                numR += 1

            else:

                heappush(PQR, a)

                sumR += a

                numR += 1



    else:  # 求値

        x = -PQL[0]

        fx = numL*x - sumL + sumR - numR*x + sumB

        anss.append((x, fx))



print(('\n'.join([str(x[0])+' '+str(x[1]) for x in anss])))

from heapq import heapify, heappush, heappop
import sys

input = sys.stdin.readline
Q = int(eval(input()))
ss = eval(input())
t, A, B = list(map(int, ss.split()))
PQ1, PQ2 = [-A], [A]
fr = to = A
minF = 0
accB = B
anss = []
for _ in range(Q - 1):
    ss = eval(input())
    if ss[0] == "1":
        t, A, B = list(map(int, ss.split()))
        if fr <= A <= to:
            heappush(PQ1, -A)
            heappush(PQ2, A)
        elif A < fr:
            p = -heappop(PQ1)
            heappush(PQ2, p)
            heappush(PQ1, -A)
            heappush(PQ1, -A)
            minF += fr - A
        else:
            p = heappop(PQ2)
            heappush(PQ1, -p)
            heappush(PQ2, A)
            heappush(PQ2, A)
            minF += A - to
        fr = -heappop(PQ1)
        to = heappop(PQ2)
        heappush(PQ1, -fr)
        heappush(PQ2, to)
        accB += B
    else:
        anss.append((fr, minF + accB))
print(("\n".join([str(x[0]) + " " + str(x[1]) for x in anss])))

from heapq import heapify, heappush, heappop
import sys

input = sys.stdin.readline
Q = int(eval(input()))
querys = [tuple(map(int, input().split())) for _ in range(Q)]
anss = []
PQL, PQR = [], []
sumL = sumR = 0
numL = numR = 0
sumB = 0
for query in querys:
    if query[0] == 1:  # 更新
        a, b = query[1:]
        sumB += b
        if numL == 0:
            heappush(PQL, -a)
            sumL += a
            numL += 1
        elif numL == numR:
            if a <= -PQL[0]:
                heappush(PQL, -a)
                sumL += a
                numL += 1
            else:
                heappush(PQR, a)
                c = heappop(PQR)
                sumR += a - c
                heappush(PQL, -c)
                sumL += c
                numL += 1
        else:
            if a < -PQL[0]:
                heappush(PQL, -a)
                c = -heappop(PQL)
                sumL += a - c
                heappush(PQR, c)
                sumR += c
                numR += 1
            else:
                heappush(PQR, a)
                sumR += a
                numR += 1
    else:  # 求値
        x = -PQL[0]
        fx = numL * x - sumL + sumR - numR * x + sumB
        anss.append((x, fx))
print(("\n".join([str(x[0]) + " " + str(x[1]) for x in anss])))

-ss = eval(input()) -t, A, B = list(map(int, ss.split())) -PQ1, PQ2 = [-A], [A] -fr = to = A -minF = 0 -accB = B +querys = [tuple(map(int, input().split())) for _ in range(Q)] -for _ in range(Q - 1): -    ss = eval(input()) -    if ss[0] == "1": -        t, A, B = list(map(int, ss.split())) -        if fr <= A <= to: -            heappush(PQ1, -A) -            heappush(PQ2, A) -        elif A < fr: -            p = -heappop(PQ1) -            heappush(PQ2, p) -            heappush(PQ1, -A) -            heappush(PQ1, -A) -            minF += fr - A +PQL, PQR = [], [] +sumL = sumR = 0 +numL = numR = 0 +sumB = 0 +for query in querys: +    if query[0] == 1:  # 更新 +        a, b = query[1:] +        sumB += b +        if numL == 0: +            heappush(PQL, -a) +            sumL += a +            numL += 1 +        elif numL == numR: +            if a <= -PQL[0]: +                heappush(PQL, -a) +                sumL += a +                numL += 1 +            else: +                heappush(PQR, a) +                c = heappop(PQR) +                sumR += a - c +                heappush(PQL, -c) +                sumL += c +                numL += 1 -            p = heappop(PQ2) -            heappush(PQ1, -p) -            heappush(PQ2, A) -            heappush(PQ2, A) -            minF += A - to -        fr = -heappop(PQ1) -        to = heappop(PQ2) -        heappush(PQ1, -fr) -        heappush(PQ2, to) -        accB += B -    else: -        anss.append((fr, minF + accB)) +            if a < -PQL[0]: +                heappush(PQL, -a) +                c = -heappop(PQL) +                sumL += a - c +                heappush(PQR, c) +                sumR += c +                numR += 1 +            else: +                heappush(PQR, a) +                sumR += a +                numR += 1 +    else:  # 求値 +        x = -PQL[0] +        fx = numL * x - sumL + sumR - numR * x + sumB +        anss.append((x, fx))