import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

from bisect import insort



class BIT():

 

    def __init__(self, n):

        '''

        n = 要素数

        添字は i = 0 ~ n-1 となる

        '''

        self.n = n

        self.bit = [0] * (n + 1)

 

    def add(self, i, x):

        '''i番目の要素にxを加算する'''

        i = i + 1

        while i <= self.n:

            self.bit[i] += x

            i += i & -i

 

    def _sum(self, i):

        s = 0

        while i > 0:

            s += self.bit[i]

            i -= i & -i

        return s

 

    def get(self, i, j):

        '''[i, j)の和を求める'''

        return self._sum(j) - self._sum(i)

  

def compress(list1):

    list2 = sorted(set(list1))

    memo = {value : index for index, value in enumerate(list2)}

    return memo, len(list2)



q = int(readline())

info = [list(map(int, input().split())) for i in range(q)]

 

#座圧する

li1 = []

for i in range(q):

    if info[i][0] == 1:

        li1.append(info[i][1])

        

memo, len_memo = compress(li1)



def median():

    ok = len_memo

    ng = 0

    while abs(ok - ng) > 1:

        mid = (ok + ng) // 2

        if 2 * bit1.get(mid, len_memo) <= cnt :

            ok = mid

        else:

            ng = mid

    return memo_inv[ng]

  

#値を管理するBIT

bit = BIT(len_memo)

#要素数を管理するBITに

bit1 = BIT(len_memo)

memo_inv = dict([(v,k) for k,v in list(memo.items())])

  

s = 0

cnt = 0

for i in range(q):

  que = info[i]

  if que[0] == 1:

    a,b,c = que

    s += c

    cnt += 1

    bit.add(memo[b],b)

    bit1.add(memo[b], 1)

  else:

    d = median()

    sum1 = bit.get(0, memo[d])

    num1 = bit1.get(0, memo[d])

    sum2 = bit.get(memo[d], len_memo)

    num2 = bit1.get(memo[d], len_memo)

    print((d, abs(num1*d- sum1) + abs(num2*d - sum2) + s))
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline



class Bit:

    def __init__(self, n):

        self.size = n

        self.tree = [0] * (n + 1)

        self.depth = n.bit_length()

 

    def sum(self, i):

        s = 0

        while i > 0:

            s += self.tree[i]

            i -= i & -i

        return s

 

    def add(self, i, x):

        while i <= self.size:

            self.tree[i] += x

            i += i & -i

 

    def lower_bound(self, x):

        """ 累積和がx以上になる最小のindexと、その直前までの累積和 """

        sum_ = 0

        pos = 0

        for i in range(self.depth, -1, -1):

            k = pos + (1 << i)

            if k <= self.size and sum_ + self.tree[k] < x:

                sum_ += self.tree[k]

                pos += 1 << i

        return pos + 1

  

def compress(list1):

    list2 = sorted(set(list1))

    memo = {value : index for index, value in enumerate(list2)}

    return memo, len(list2)



q = int(readline())

L = [list(map(int,readline().split())) for i in range(q)]

 

#座圧する

chk = []

for i in range(q):

    if L[i][0] == 1:

        chk.append(L[i][1])

        

memo, len_memo = compress(chk)

memo_inv = dict([(v,k) for k,v in list(memo.items())])



#値を管理するBIT

bit = Bit(len_memo)

#要素数を管理するBIT

num = Bit(len_memo)

  

s = 0

cnt = 0

for i in range(q):

  que = L[i]

  if que[0] == 1:

    a,b,c = que

    s += c

    cnt += 1

    bit.add(memo[b]+1,b)

    num.add(memo[b]+1,1)

  else:

    d = num.lower_bound((cnt+1)//2)

    m = memo_inv[d-1]

    sum1 = bit.sum(d)

    num1 = num.sum(d)

    sum2 = bit.sum(len_memo)-bit.sum(d)

    num2 = num.sum(len_memo)-num.sum(d)

    print((m,abs(num1*m-sum1)+abs(num2*m-sum2)+s))
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from bisect import insort


class BIT:
    def __init__(self, n):
        """
        n = 要素数
        添字は i = 0 ~ n-1 となる
        """
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, x):
        """i番目の要素にxを加算する"""
        i = i + 1
        while i <= self.n:
            self.bit[i] += x
            i += i & -i

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def get(self, i, j):
        """[i, j)の和を求める"""
        return self._sum(j) - self._sum(i)


def compress(list1):
    list2 = sorted(set(list1))
    memo = {value: index for index, value in enumerate(list2)}
    return memo, len(list2)


q = int(readline())
info = [list(map(int, input().split())) for i in range(q)]
# 座圧する
li1 = []
for i in range(q):
    if info[i][0] == 1:
        li1.append(info[i][1])
memo, len_memo = compress(li1)


def median():
    ok = len_memo
    ng = 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if 2 * bit1.get(mid, len_memo) <= cnt:
            ok = mid
        else:
            ng = mid
    return memo_inv[ng]


# 値を管理するBIT
bit = BIT(len_memo)
# 要素数を管理するBITに
bit1 = BIT(len_memo)
memo_inv = dict([(v, k) for k, v in list(memo.items())])
s = 0
cnt = 0
for i in range(q):
    que = info[i]
    if que[0] == 1:
        a, b, c = que
        s += c
        cnt += 1
        bit.add(memo[b], b)
        bit1.add(memo[b], 1)
    else:
        d = median()
        sum1 = bit.get(0, memo[d])
        num1 = bit1.get(0, memo[d])
        sum2 = bit.get(memo[d], len_memo)
        num2 = bit1.get(memo[d], len_memo)
        print((d, abs(num1 * d - sum1) + abs(num2 * d - sum2) + s))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.depth = n.bit_length()

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def lower_bound(self, x):
        """累積和がx以上になる最小のindexと、その直前までの累積和"""
        sum_ = 0
        pos = 0
        for i in range(self.depth, -1, -1):
            k = pos + (1 << i)
            if k <= self.size and sum_ + self.tree[k] < x:
                sum_ += self.tree[k]
                pos += 1 << i
        return pos + 1


def compress(list1):
    list2 = sorted(set(list1))
    memo = {value: index for index, value in enumerate(list2)}
    return memo, len(list2)


q = int(readline())
L = [list(map(int, readline().split())) for i in range(q)]
# 座圧する
chk = []
for i in range(q):
    if L[i][0] == 1:
        chk.append(L[i][1])
memo, len_memo = compress(chk)
memo_inv = dict([(v, k) for k, v in list(memo.items())])
# 値を管理するBIT
bit = Bit(len_memo)
# 要素数を管理するBIT
num = Bit(len_memo)
s = 0
cnt = 0
for i in range(q):
    que = L[i]
    if que[0] == 1:
        a, b, c = que
        s += c
        cnt += 1
        bit.add(memo[b] + 1, b)
        num.add(memo[b] + 1, 1)
    else:
        d = num.lower_bound((cnt + 1) // 2)
        m = memo_inv[d - 1]
        sum1 = bit.sum(d)
        num1 = num.sum(d)
        sum2 = bit.sum(len_memo) - bit.sum(d)
        num2 = num.sum(len_memo) - num.sum(d)
        print((m, abs(num1 * m - sum1) + abs(num2 * m - sum2) + s))

-from bisect import insort -class BIT: +class Bit: -        """ -        n = 要素数 -        添字は i = 0 ~ n-1 となる -        """ -        self.n = n -        self.bit = [0] * (n + 1) +        self.size = n +        self.tree = [0] * (n + 1) +        self.depth = n.bit_length() -    def add(self, i, x): -        """i番目の要素にxを加算する""" -        i = i + 1 -        while i <= self.n: -            self.bit[i] += x -            i += i & -i - -    def _sum(self, i): +    def sum(self, i): -            s += self.bit[i] +            s += self.tree[i] -    def get(self, i, j): -        """[i, j)の和を求める""" -        return self._sum(j) - self._sum(i) +    def add(self, i, x): +        while i <= self.size: +            self.tree[i] += x +            i += i & -i + +    def lower_bound(self, x): +        """累積和がx以上になる最小のindexと、その直前までの累積和""" +        sum_ = 0 +        pos = 0 +        for i in range(self.depth, -1, -1): +            k = pos + (1 << i) +            if k <= self.size and sum_ + self.tree[k] < x: +                sum_ += self.tree[k] +                pos += 1 << i +        return pos + 1 -info = [list(map(int, input().split())) for i in range(q)] +L = [list(map(int, readline().split())) for i in range(q)] -li1 = [] +chk = [] -    if info[i][0] == 1: -        li1.append(info[i][1]) -memo, len_memo = compress(li1) - - -def median(): -    ok = len_memo -    ng = 0 -    while abs(ok - ng) > 1: -        mid = (ok + ng) // 2 -        if 2 * bit1.get(mid, len_memo) <= cnt: -            ok = mid -        else: -            ng = mid -    return memo_inv[ng] - - +    if L[i][0] == 1: +        chk.append(L[i][1]) +memo, len_memo = compress(chk) +memo_inv = dict([(v, k) for k, v in list(memo.items())]) -bit = BIT(len_memo) -# 要素数を管理するBITに -bit1 = BIT(len_memo) -memo_inv = dict([(v, k) for k, v in list(memo.items())]) +bit = Bit(len_memo) +# 要素数を管理するBIT +num = Bit(len_memo) -    que = info[i] +    que = L[i] -        bit.add(memo[b], b) -        bit1.add(memo[b], 1) +        bit.add(memo[b] + 1, b) +        num.add(memo[b] + 1, 1) -        d = median() -        sum1 = bit.get(0, memo[d]) -        num1 = bit1.get(0, memo[d]) -        sum2 = bit.get(memo[d], len_memo) -        num2 = bit1.get(memo[d], len_memo) -        print((d, abs(num1 * d - sum1) + abs(num2 * d - sum2) + s)) +        d = num.lower_bound((cnt + 1) // 2) +        m = memo_inv[d - 1] +        sum1 = bit.sum(d) +        num1 = num.sum(d) +        sum2 = bit.sum(len_memo) - bit.sum(d) +        num2 = num.sum(len_memo) - num.sum(d) +        print((m, abs(num1 * m - sum1) + abs(num2 * m - sum2) + s))