from heapq import heappop, heappush

import sys



input = sys.stdin.readline





class median_o1:

    def __init__(self):

        self.count = 0

        self.al = []

        self.ar = []

        self.sl = 0

        self.sr = 0

        self.b = 0



    def update_b(self, b):

        self.b += b



    def insert(self, x):

        if self.count % 2 == 0:

            if self.count == 0:

                heappush(self.al, -x)

                self.sl += x

            else:

                t = heappop(self.ar)

                self.sr -= t

                tl, tr = min(x, t), max(x, t)

                heappush(self.al, -tl)

                self.sl += tl

                heappush(self.ar, tr)

                self.sr += tr

        else:

            t = heappop(self.al)

            t *= (-1)

            self.sl -= t

            tl, tr = min(x, t), max(x, t)

            heappush(self.ar, tr)

            self.sr += tr

            heappush(self.al, -tl)

            self.sl += tl

        self.count += 1



    def get_median(self):

        return -self.al[0]



    def calc_min_value(self):

        # print(self.al, self.ar, self.b, self.sl, self.sr)

        m = self.get_median()

        return (m * ((self.count + 1) // 2) - self.sl) + (self.sr - m * (self.count // 2)) + self.b





q = int(eval(input()))



m = median_o1()



for _ in range(q):

    q_typ, *x = list(map(int, input().split()))

    # 1, [a, b]

    # 2, []

    if q_typ == 1:

        m.update_b(x[1])

        m.insert(x[0])

    else:

        print((m.get_median(), m.calc_min_value()))

def main():

    from heapq import heappush, heappop, heappushpop

    import sys



    input = sys.stdin.readline



    class Median:

        def __init__(self):

            self.b = 0

            self.l = []

            self.sum_l = 0

            self.r = []

            self.sum_r = 0



        def update(self, a: int, b: int) -> None:

            self.b += b



            size = len(self.l) + len(self.r)

            if size % 2 == 0:

                x = heappushpop(self.r, a)

                self.sum_r += a - x

                heappush(self.l, -x)

                self.sum_l += x

            else:

                x = heappushpop(self.l, -a)

                self.sum_l += a + x  # a - (-x)

                heappush(self.r, -x)

                self.sum_r -= x  # += (-x)



        def query(self):

            median = -self.l[0]

            ret = (abs(len(self.l) * median - self.sum_l)

                   + abs(self.sum_r - len(self.r) * median)

                   + self.b)

            return median, ret



    med = Median()

    n = int(eval(input()))

    for _ in range(n):

        q = iter(input().rstrip().split())

        if next(q) == '1':

            med.update(*list(map(int, q)))

        else:

            print((*med.query()))





if __name__ == '__main__':

    main()

from heapq import heappop, heappush
import sys

input = sys.stdin.readline


class median_o1:
    def __init__(self):
        self.count = 0
        self.al = []
        self.ar = []
        self.sl = 0
        self.sr = 0
        self.b = 0

    def update_b(self, b):
        self.b += b

    def insert(self, x):
        if self.count % 2 == 0:
            if self.count == 0:
                heappush(self.al, -x)
                self.sl += x
            else:
                t = heappop(self.ar)
                self.sr -= t
                tl, tr = min(x, t), max(x, t)
                heappush(self.al, -tl)
                self.sl += tl
                heappush(self.ar, tr)
                self.sr += tr
        else:
            t = heappop(self.al)
            t *= -1
            self.sl -= t
            tl, tr = min(x, t), max(x, t)
            heappush(self.ar, tr)
            self.sr += tr
            heappush(self.al, -tl)
            self.sl += tl
        self.count += 1

    def get_median(self):
        return -self.al[0]

    def calc_min_value(self):
        # print(self.al, self.ar, self.b, self.sl, self.sr)
        m = self.get_median()
        return (
            (m * ((self.count + 1) // 2) - self.sl)
            + (self.sr - m * (self.count // 2))
            + self.b
        )


q = int(eval(input()))
m = median_o1()
for _ in range(q):
    q_typ, *x = list(map(int, input().split()))
    # 1, [a, b]
    # 2, []
    if q_typ == 1:
        m.update_b(x[1])
        m.insert(x[0])
    else:
        print((m.get_median(), m.calc_min_value()))

def main():
    from heapq import heappush, heappop, heappushpop
    import sys

    input = sys.stdin.readline

    class Median:
        def __init__(self):
            self.b = 0
            self.l = []
            self.sum_l = 0
            self.r = []
            self.sum_r = 0

        def update(self, a: int, b: int) -> None:
            self.b += b
            size = len(self.l) + len(self.r)
            if size % 2 == 0:
                x = heappushpop(self.r, a)
                self.sum_r += a - x
                heappush(self.l, -x)
                self.sum_l += x
            else:
                x = heappushpop(self.l, -a)
                self.sum_l += a + x  # a - (-x)
                heappush(self.r, -x)
                self.sum_r -= x  # += (-x)

        def query(self):
            median = -self.l[0]
            ret = (
                abs(len(self.l) * median - self.sum_l)
                + abs(self.sum_r - len(self.r) * median)
                + self.b
            )
            return median, ret

    med = Median()
    n = int(eval(input()))
    for _ in range(n):
        q = iter(input().rstrip().split())
        if next(q) == "1":
            med.update(*list(map(int, q)))
        else:
            print((*med.query()))


if __name__ == "__main__":
    main()

-from heapq import heappop, heappush -import sys +def main(): +    from heapq import heappush, heappop, heappushpop +    import sys -input = sys.stdin.readline +    input = sys.stdin.readline + +    class Median: +        def __init__(self): +            self.b = 0 +            self.l = [] +            self.sum_l = 0 +            self.r = [] +            self.sum_r = 0 + +        def update(self, a: int, b: int) -> None: +            self.b += b +            size = len(self.l) + len(self.r) +            if size % 2 == 0: +                x = heappushpop(self.r, a) +                self.sum_r += a - x +                heappush(self.l, -x) +                self.sum_l += x +            else: +                x = heappushpop(self.l, -a) +                self.sum_l += a + x  # a - (-x) +                heappush(self.r, -x) +                self.sum_r -= x  # += (-x) + +        def query(self): +            median = -self.l[0] +            ret = ( +                abs(len(self.l) * median - self.sum_l) +                + abs(self.sum_r - len(self.r) * median) +                + self.b +            ) +            return median, ret + +    med = Median() +    n = int(eval(input())) +    for _ in range(n): +        q = iter(input().rstrip().split()) +        if next(q) == "1": +            med.update(*list(map(int, q))) +        else: +            print((*med.query())) -class median_o1: -    def __init__(self): -        self.count = 0 -        self.al = [] -        self.ar = [] -        self.sl = 0 -        self.sr = 0 -        self.b = 0 - -    def update_b(self, b): -        self.b += b - -    def insert(self, x): -        if self.count % 2 == 0: -            if self.count == 0: -                heappush(self.al, -x) -                self.sl += x -            else: -                t = heappop(self.ar) -                self.sr -= t -                tl, tr = min(x, t), max(x, t) -                heappush(self.al, -tl) -                self.sl += tl -                heappush(self.ar, tr) -                self.sr += tr -        else: -            t = heappop(self.al) -            t *= -1 -            self.sl -= t -            tl, tr = min(x, t), max(x, t) -            heappush(self.ar, tr) -            self.sr += tr -            heappush(self.al, -tl) -            self.sl += tl -        self.count += 1 - -    def get_median(self): -        return -self.al[0] - -    def calc_min_value(self): -        # print(self.al, self.ar, self.b, self.sl, self.sr) -        m = self.get_median() -        return ( -            (m * ((self.count + 1) // 2) - self.sl) -            + (self.sr - m * (self.count // 2)) -            + self.b -        ) - - -q = int(eval(input())) -m = median_o1() -for _ in range(q): -    q_typ, *x = list(map(int, input().split())) -    # 1, [a, b] -    # 2, [] -    if q_typ == 1: -        m.update_b(x[1]) -        m.insert(x[0]) -    else: -        print((m.get_median(), m.calc_min_value())) +if __name__ == "__main__": +    main()