from heapq import *

Q = int(eval(input()))

L, R = [], []

ans = 0

for _ in range(Q):

    a = [int(a) for a in input().split()]

    if a[0] == 1:

        ans += a[2]

        if len(L) == 0 or a[1] <= -L[0]:

            heappush(L, -a[1])

            ans += -L[0] - a[1]

        else:

            heappush(R, a[1])

            ans += a[1] + L[0]

        if len(R) > len(L):

            ans -= R[0] + L[0]

            heappush(L, -heappop(R))

        elif len(L) - len(R) >= 2:

            heappush(R, -heappop(L))

    else:

        print((-L[0], ans))
import sys

input = sys.stdin.readline

from heapq import *

Q = int(eval(input()))

L, R = [], []

ans = 0

for _ in range(Q):

    a = [int(a) for a in input().split()]

    if a[0] == 1:

        ans += a[2]

        if len(L) == 0 or a[1] <= -L[0]:

            heappush(L, -a[1])

            ans += -L[0] - a[1]

        else:

            heappush(R, a[1])

            ans += a[1] + L[0]

        if len(R) > len(L):

            ans -= R[0] + L[0]

            heappush(L, -heappop(R))

        elif len(L) - len(R) >= 2:

            heappush(R, -heappop(L))

    else:

        print((-L[0], ans))

from heapq import *

Q = int(eval(input()))
L, R = [], []
ans = 0
for _ in range(Q):
    a = [int(a) for a in input().split()]
    if a[0] == 1:
        ans += a[2]
        if len(L) == 0 or a[1] <= -L[0]:
            heappush(L, -a[1])
            ans += -L[0] - a[1]
        else:
            heappush(R, a[1])
            ans += a[1] + L[0]
        if len(R) > len(L):
            ans -= R[0] + L[0]
            heappush(L, -heappop(R))
        elif len(L) - len(R) >= 2:
            heappush(R, -heappop(L))
    else:
        print((-L[0], ans))

import sys

input = sys.stdin.readline
from heapq import *

Q = int(eval(input()))
L, R = [], []
ans = 0
for _ in range(Q):
    a = [int(a) for a in input().split()]
    if a[0] == 1:
        ans += a[2]
        if len(L) == 0 or a[1] <= -L[0]:
            heappush(L, -a[1])
            ans += -L[0] - a[1]
        else:
            heappush(R, a[1])
            ans += a[1] + L[0]
        if len(R) > len(L):
            ans -= R[0] + L[0]
            heappush(L, -heappop(R))
        elif len(L) - len(R) >= 2:
            heappush(R, -heappop(L))
    else:
        print((-L[0], ans))

+import sys + +input = sys.stdin.readline