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()

def main():

    from heapq import heappop, heappush

    import sys

    input = sys.stdin.readline



    Q = int(eval(input()))



    left = []

    right = []

    sum_l = 0

    sum_r = 0

    cnt = 0

    b = 0

    for _ in range(Q):

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

        t = next(query)

        if t == 1:

            x, b_ = query

            b += b_

            cnt += 1

            if cnt % 2 == 0:

                heappush(left, -x)

                sum_l += x

                x = -heappop(left)

                sum_l -= x

                heappush(right, x)

                sum_r += x

            else:

                heappush(right, x)

                sum_r += x

                x = heappop(right)

                sum_r -= x

                heappush(left, -x)

                sum_l += x

        else:

            x = -left[0]

            ans = b + sum_r - sum_l + x * (cnt % 2)

            print((x, ans))





if __name__ == '__main__':

    main()



# import sys

# input = sys.stdin.readline

#

# sys.setrecursionlimit(10 ** 7)

#

# (int(x)-1 for x in input().split())

# rstrip()

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()

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

    input = sys.stdin.readline
    Q = int(eval(input()))
    left = []
    right = []
    sum_l = 0
    sum_r = 0
    cnt = 0
    b = 0
    for _ in range(Q):
        query = list(map(int, input().split()))
        t = next(query)
        if t == 1:
            x, b_ = query
            b += b_
            cnt += 1
            if cnt % 2 == 0:
                heappush(left, -x)
                sum_l += x
                x = -heappop(left)
                sum_l -= x
                heappush(right, x)
                sum_r += x
            else:
                heappush(right, x)
                sum_r += x
                x = heappop(right)
                sum_r -= x
                heappush(left, -x)
                sum_l += x
        else:
            x = -left[0]
            ans = b + sum_r - sum_l + x * (cnt % 2)
            print((x, ans))


if __name__ == "__main__":
    main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()

-    from heapq import heappush, heappop, heappushpop +    from heapq import heappop, heappush - -    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 +    Q = int(eval(input())) +    left = [] +    right = [] +    sum_l = 0 +    sum_r = 0 +    cnt = 0 +    b = 0 +    for _ in range(Q): +        query = list(map(int, input().split())) +        t = next(query) +        if t == 1: +            x, b_ = query +            b += b_ +            cnt += 1 +            if cnt % 2 == 0: +                heappush(left, -x) +                sum_l += x +                x = -heappop(left) +                sum_l -= x +                heappush(right, x) +                sum_r += x -                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))) +                heappush(right, x) +                sum_r += x +                x = heappop(right) +                sum_r -= x +                heappush(left, -x) +                sum_l += x -            print((*med.query())) +            x = -left[0] +            ans = b + sum_r - sum_l + x * (cnt % 2) +            print((x, ans)) +# import sys +# input = sys.stdin.readline +# +# sys.setrecursionlimit(10 ** 7) +# +# (int(x)-1 for x in input().split()) +# rstrip()