# youtube

from heapq import *



q = int(eval(input()))

sum_a = 0

sum_b = 0

L = []

R = []

for _ in range(q):

    qi = list(map(int, input().split()))

    if qi[0] == 1:

        a = qi[1]

        heappush(L, -a)

        heappush(R, a)

        if -L[0] > R[0]:

            LtoR = -heappop(L)

            RtoL = heappop(R)

            sum_a += LtoR - RtoL

            heappush(L, -RtoL)

            heappush(R, LtoR)

        sum_b += qi[2]

    else:

        print((-L[0], sum_a + sum_b))

from heapq import *

import sys



sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

p2D = lambda x: print(*x, sep="\n")

def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return sys.stdin.readline()[:-1]

dij=[(1,0),(-1,0),(0,1),(0,-1)]



def main():

    sa = sb = 0

    hp1 = []

    hp2 = []

    m = None

    for _ in range(II()):

        ab=input().split()

        if ab[0]=="1":

            a,b=int(ab[1]),int(ab[2])

            sb+=b

            heappush(hp1,-a)

            heappush(hp2,a)

            while -hp1[0]>hp2[0]:

                heappush(hp1,-heappop(hp2))

                heappush(hp2,-heappop(hp1))

            if m==None:

                m=a

                continue

            if -hp1[0]>m:

                d=-hp1[0]-m

                sa+=(len(hp1)-1)//2*d-(len(hp2)+1)//2*d

            if -hp1[0]<m:

                d=hp1[0]+m

                sa+=-(len(hp1))//2*d+(len(hp2))//2*d

            sa += abs(m - a)

            m=-hp1[0]

        else:

            print(m,sa+sb)



main()

# youtube
from heapq import *

q = int(eval(input()))
sum_a = 0
sum_b = 0
L = []
R = []
for _ in range(q):
    qi = list(map(int, input().split()))
    if qi[0] == 1:
        a = qi[1]
        heappush(L, -a)
        heappush(R, a)
        if -L[0] > R[0]:
            LtoR = -heappop(L)
            RtoL = heappop(R)
            sum_a += LtoR - RtoL
            heappush(L, -RtoL)
            heappush(R, LtoR)
        sum_b += qi[2]
    else:
        print((-L[0], sum_a + sum_b))

from heapq import *
import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number):
    return [LI() for _ in range(rows_number)]


def SI():
    return sys.stdin.readline()[:-1]


dij = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def main():
    sa = sb = 0
    hp1 = []
    hp2 = []
    m = None
    for _ in range(II()):
        ab = input().split()
        if ab[0] == "1":
            a, b = int(ab[1]), int(ab[2])
            sb += b
            heappush(hp1, -a)
            heappush(hp2, a)
            while -hp1[0] > hp2[0]:
                heappush(hp1, -heappop(hp2))
                heappush(hp2, -heappop(hp1))
            if m == None:
                m = a
                continue
            if -hp1[0] > m:
                d = -hp1[0] - m
                sa += (len(hp1) - 1) // 2 * d - (len(hp2) + 1) // 2 * d
            if -hp1[0] < m:
                d = hp1[0] + m
                sa += -(len(hp1)) // 2 * d + (len(hp2)) // 2 * d
            sa += abs(m - a)
            m = -hp1[0]
        else:
            print(m, sa + sb)


main()

-# youtube +import sys -q = int(eval(input())) -sum_a = 0 -sum_b = 0 -L = [] -R = [] -for _ in range(q): -    qi = list(map(int, input().split())) -    if qi[0] == 1: -        a = qi[1] -        heappush(L, -a) -        heappush(R, a) -        if -L[0] > R[0]: -            LtoR = -heappop(L) -            RtoL = heappop(R) -            sum_a += LtoR - RtoL -            heappush(L, -RtoL) -            heappush(R, LtoR) -        sum_b += qi[2] -    else: -        print((-L[0], sum_a + sum_b)) +sys.setrecursionlimit(10**6) +int1 = lambda x: int(x) - 1 +p2D = lambda x: print(*x, sep="\n") + + +def II(): +    return int(sys.stdin.readline()) + + +def MI(): +    return map(int, sys.stdin.readline().split()) + + +def LI(): +    return list(map(int, sys.stdin.readline().split())) + + +def LLI(rows_number): +    return [LI() for _ in range(rows_number)] + + +def SI(): +    return sys.stdin.readline()[:-1] + + +dij = [(1, 0), (-1, 0), (0, 1), (0, -1)] + + +def main(): +    sa = sb = 0 +    hp1 = [] +    hp2 = [] +    m = None +    for _ in range(II()): +        ab = input().split() +        if ab[0] == "1": +            a, b = int(ab[1]), int(ab[2]) +            sb += b +            heappush(hp1, -a) +            heappush(hp2, a) +            while -hp1[0] > hp2[0]: +                heappush(hp1, -heappop(hp2)) +                heappush(hp2, -heappop(hp1)) +            if m == None: +                m = a +                continue +            if -hp1[0] > m: +                d = -hp1[0] - m +                sa += (len(hp1) - 1) // 2 * d - (len(hp2) + 1) // 2 * d +            if -hp1[0] < m: +                d = hp1[0] + m +                sa += -(len(hp1)) // 2 * d + (len(hp2)) // 2 * d +            sa += abs(m - a) +            m = -hp1[0] +        else: +            print(m, sa + sb) + + +main()