import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



from heapq import heappush, heappop



Q = int(readline())

query = (tuple(map(int,line.split())) for line in readlines())



# 適当に番兵を入れておく

INF = 10**12

L = [INF] # -1倍していれる

R = [INF]

sumL = 0; sumR = 0 # 和

lenL = 0; lenR = 0 # 長さ



add = 0 # 全体に共通に加わってるもの



answer = []

for q in query:

    if len(q) == 1:

        # 値を求める

        x = -L[0]

        f = sumR - sumL + x * (lenL - lenR)

        answer.append('{} {}'.format(x,f+add))

        continue

    # 更新

    a,b = q[1:]

    add += b

    

    b = -heappop(L); sumL -= b

    c = heappop(R); sumR -= c

    a,b,c = sorted([a,b,c])

    heappush(L,-a); sumL += a

    heappush(R,c); sumR += c

    if lenL > lenR:

        heappush(R,b); sumR += b; lenR += 1

    else:

        heappush(L,-b); sumL += b; lenL += 1



print(('\n'.join(answer)))
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



from heapq import heappush, heappop, heappushpop



Q = int(readline())

query = (tuple(map(int,line.split())) for line in readlines())



# 適当に番兵を入れておく

INF = 10**12

L = [INF] # -1倍していれる

R = [INF]

sumL = 0; sumR = 0 # 和

lenL = 0; lenR = 0 # 長さ



add = 0 # 全体に共通に加わってるもの



answer = []

for q in query:

    if len(q) == 1:

        # 値を求める

        x = -L[0]

        f = sumR - sumL + x * (lenL - lenR)

        answer.append('{} {}'.format(x,f+add))

        continue

    # 更新

    a,b = q[1:]

    add += b

    if lenL > lenR:

        sumL += a; a = -heappushpop(L,-a); sumL -= a

        heappush(R,a); sumR += a; lenR += 1

    else:

        sumR += a; a = heappushpop(R,a); sumR -= a

        heappush(L,-a); sumL += a; lenL += 1



print(('\n'.join(answer)))
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappush, heappop

Q = int(readline())
query = (tuple(map(int, line.split())) for line in readlines())
# 適当に番兵を入れておく
INF = 10**12
L = [INF]  # -1倍していれる
R = [INF]
sumL = 0
sumR = 0  # 和
lenL = 0
lenR = 0  # 長さ
add = 0  # 全体に共通に加わってるもの
answer = []
for q in query:
    if len(q) == 1:
        # 値を求める
        x = -L[0]
        f = sumR - sumL + x * (lenL - lenR)
        answer.append("{} {}".format(x, f + add))
        continue
    # 更新
    a, b = q[1:]
    add += b
    b = -heappop(L)
    sumL -= b
    c = heappop(R)
    sumR -= c
    a, b, c = sorted([a, b, c])
    heappush(L, -a)
    sumL += a
    heappush(R, c)
    sumR += c
    if lenL > lenR:
        heappush(R, b)
        sumR += b
        lenR += 1
    else:
        heappush(L, -b)
        sumL += b
        lenL += 1
print(("\n".join(answer)))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappush, heappop, heappushpop

Q = int(readline())
query = (tuple(map(int, line.split())) for line in readlines())
# 適当に番兵を入れておく
INF = 10**12
L = [INF]  # -1倍していれる
R = [INF]
sumL = 0
sumR = 0  # 和
lenL = 0
lenR = 0  # 長さ
add = 0  # 全体に共通に加わってるもの
answer = []
for q in query:
    if len(q) == 1:
        # 値を求める
        x = -L[0]
        f = sumR - sumL + x * (lenL - lenR)
        answer.append("{} {}".format(x, f + add))
        continue
    # 更新
    a, b = q[1:]
    add += b
    if lenL > lenR:
        sumL += a
        a = -heappushpop(L, -a)
        sumL -= a
        heappush(R, a)
        sumR += a
        lenR += 1
    else:
        sumR += a
        a = heappushpop(R, a)
        sumR -= a
        heappush(L, -a)
        sumL += a
        lenL += 1
print(("\n".join(answer)))

-from heapq import heappush, heappop +from heapq import heappush, heappop, heappushpop -    b = -heappop(L) -    sumL -= b -    c = heappop(R) -    sumR -= c -    a, b, c = sorted([a, b, c]) -    heappush(L, -a) -    sumL += a -    heappush(R, c) -    sumR += c -        heappush(R, b) -        sumR += b +        sumL += a +        a = -heappushpop(L, -a) +        sumL -= a +        heappush(R, a) +        sumR += a -        heappush(L, -b) -        sumL += b +        sumR += a +        a = heappushpop(R, a) +        sumR -= a +        heappush(L, -a) +        sumL += a