from heapq import heappush, heappop, heappushpop

import sys

#input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))



Q = int(eval(input()))

L = []

R = []



B = 0

M = 0



for _ in range(Q):

    q = inpl()

    if len(q) == 3:

        B += q[2]

        if len(R) == 0:

            L.append(-q[1])

            R.append(q[1])

            continue



        M += min(abs(-L[0] - q[1]), abs(R[0] - q[1])) * (not (-L[0] <= q[1] <= R[0]))

        if q[1] < R[0]:

            heappush(L, -q[1])

            heappush(R, -heappushpop(L, -q[1]))

        else:

            heappush(R, q[1])

            heappush(L, -heappushpop(R, q[1]))

    else:

        print((-L[0], B+M))
from heapq import heappush, heappop, heappushpop

import sys

input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))



Q = int(eval(input()))

L = []

R = []



B = 0

M = 0



for _ in range(Q):

    q = inpl()

    if len(q) == 3:

        B += q[2]

        if len(R) == 0:

            L.append(-q[1])

            R.append(q[1])

            continue



        M += min(abs(-L[0] - q[1]), abs(R[0] - q[1])) * (not (-L[0] <= q[1] <= R[0]))

        if q[1] < R[0]:

            heappush(L, -q[1])

            heappush(R, -heappushpop(L, -q[1]))

        else:

            heappush(R, q[1])

            heappush(L, -heappushpop(R, q[1]))

    else:

        print((-L[0], B+M))
from heapq import heappush, heappop, heappushpop
import sys

# input = sys.stdin.readline
def inpl():
    return list(map(int, input().split()))


Q = int(eval(input()))
L = []
R = []
B = 0
M = 0
for _ in range(Q):
    q = inpl()
    if len(q) == 3:
        B += q[2]
        if len(R) == 0:
            L.append(-q[1])
            R.append(q[1])
            continue
        M += min(abs(-L[0] - q[1]), abs(R[0] - q[1])) * (not (-L[0] <= q[1] <= R[0]))
        if q[1] < R[0]:
            heappush(L, -q[1])
            heappush(R, -heappushpop(L, -q[1]))
        else:
            heappush(R, q[1])
            heappush(L, -heappushpop(R, q[1]))
    else:
        print((-L[0], B + M))

from heapq import heappush, heappop, heappushpop
import sys

input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


Q = int(eval(input()))
L = []
R = []
B = 0
M = 0
for _ in range(Q):
    q = inpl()
    if len(q) == 3:
        B += q[2]
        if len(R) == 0:
            L.append(-q[1])
            R.append(q[1])
            continue
        M += min(abs(-L[0] - q[1]), abs(R[0] - q[1])) * (not (-L[0] <= q[1] <= R[0]))
        if q[1] < R[0]:
            heappush(L, -q[1])
            heappush(R, -heappushpop(L, -q[1]))
        else:
            heappush(R, q[1])
            heappush(L, -heappushpop(R, q[1]))
    else:
        print((-L[0], B + M))

-# input = sys.stdin.readline +input = sys.stdin.readline + +