### BUGGY CODE ###

import heapq
import sys

# from matplotlib import pyplot as plt

sys.setrecursionlimit(10000)
INF = float('inf')

Q = int(input())

# def plot(fn):
#     x = np.arange(-10, 10, 1)
#     y = np.array([fn(xa) for xa in x])
#     plt.plot(x, y)
#     plt.grid()
#     plt.show()
#
#
# def g(fn, a, b):
#     return lambda x: fn(x) + abs(x - a) + b
#
#
# f = lambda x: 0
# i = 0
# for _ in range(Q):
#     q = list(map(int, input().split()))
#     if q[0] == 1:
#         a, b = q[1], q[2]
#         f = g(f, a, b)
#     else:
#         plot(f)


# a をソートしたときに真ん中に来る値 x が最小値を持つ
# 中央値しか必要ないのでヒープ 2 つ作って管理
# 中央値より小さいやつ
smalls = []
# 中央値より大きいやつ
larges = []
# こたえ f(x) の最小値
fmin = 0
prev_x = None
for _ in range(Q):
    q = list(map(int, input().split()))
    if q[0] == 1:
        a, b = q[1], q[2]

        # 適切な方に入れる
        if not larges or a > larges[0]:
            heapq.heappush(larges, a)
        else:
            heapq.heappush(smalls, -a)
        # 偏り解消
        if len(larges) > len(smalls) + 1:
            heapq.heappush(smalls, -heapq.heappop(larges))
        elif len(smalls) > len(larges) + 1:
            heapq.heappush(larges, -heapq.heappop(smalls))

        # x は a の中央値
        if len(smalls) >= len(larges):
            x = -smalls[0]
        else:
            x = larges[0]

        fmin += abs(x - a) + b
        if x != prev_x:
            if prev_x is not None and len(smalls) == len(larges):
                fmin += abs(x - prev_x)
            prev_x = x
    else:
        if len(smalls) >= len(larges):
            x = -smalls[0]
        else:
            x = larges[0]
        print(x, fmin)


### FIXED CODE ###

import heapq
import sys

# from matplotlib import pyplot as plt

sys.setrecursionlimit(10000)
INF = float('inf')

Q = int(next(sys.stdin))

# def plot(fn):
#     x = np.arange(-10, 10, 1)
#     y = np.array([fn(xa) for xa in x])
#     plt.plot(x, y)
#     plt.grid()
#     plt.show()
#
#
# def g(fn, a, b):
#     return lambda x: fn(x) + abs(x - a) + b
#
#
# f = lambda x: 0
# i = 0
# for _ in range(Q):
#     q = list(map(int, input().split()))
#     if q[0] == 1:
#         a, b = q[1], q[2]
#         f = g(f, a, b)
#     else:
#         plot(f)


# a をソートしたときに真ん中に来る値 x が最小値を持つ
# 中央値しか必要ないのでヒープ 2 つ作って管理
# 中央値より小さいやつ
smalls = []
# 中央値より大きいやつ
larges = []
# こたえ f(x) の最小値
fmin = 0
prev_x = None
for _ in range(Q):
    q = list(map(int, next(sys.stdin).split()))
    if q[0] == 1:
        a, b = q[1], q[2]

        # 適切な方に入れる
        if not larges or a > larges[0]:
            heapq.heappush(larges, a)
        else:
            heapq.heappush(smalls, -a)
        # 偏り解消
        if len(larges) > len(smalls) + 1:
            heapq.heappush(smalls, -heapq.heappop(larges))
        elif len(smalls) > len(larges) + 1:
            heapq.heappush(larges, -heapq.heappop(smalls))

        # x は a の中央値
        if len(smalls) >= len(larges):
            x = -smalls[0]
        else:
            x = larges[0]

        fmin += abs(x - a) + b
        if x != prev_x:
            if prev_x is not None and len(smalls) == len(larges):
                fmin += abs(x - prev_x)
            prev_x = x
    else:
        if len(smalls) >= len(larges):
            x = -smalls[0]
        else:
            x = larges[0]
        print(x, fmin)