from heapq import heappop, heappush





def main():

    Q = int(input())

    y = 0

    lheap = []

    rheap = []

    lsum = 0

    rsum = 0

    for _ in range(Q):

        q = input()

        if q[0] == '1':

            # update

            _, a, b = map(int, q.split())

            y += b

            if len(lheap) == 0 or -lheap[0] <= a <= rheap[0]:

                heappush(lheap, -a)

                heappush(rheap, a)

                lsum += a

                rsum += a

            elif a < -lheap[0]:

                mov = -heappop(lheap)

                heappush(rheap, mov)

                heappush(lheap, -a)

                heappush(lheap, -a)

                lsum += a*2 - mov

                rsum += mov

            elif rheap[0] < a:

                mov = heappop(rheap)

                heappush(lheap, -mov)

                heappush(rheap, a)

                heappush(rheap, a)

                lsum += mov

                rsum += a*2 - mov

        else:

            # inquiry

            x = -lheap[0]

            minimum = abs(x * len(lheap) - lsum) // 2 + \

                abs(x * len(rheap) - rsum) // 2 + y

            print(x, minimum)





if __name__ == "__main__":

    main()

from heapq import heappop, heappush

import sys

input = sys.stdin.readline





def main():

    Q = int(input())

    y = 0

    lheap = []

    rheap = []

    lsum = 0

    rsum = 0

    for _ in range(Q):

        q = input()

        if q[0] == '1':

            # update

            _, a, b = map(int, q.split())

            y += b

            if len(lheap) == 0 or -lheap[0] <= a <= rheap[0]:

                heappush(lheap, -a)

                heappush(rheap, a)

                lsum += a

                rsum += a

            elif a < -lheap[0]:

                mov = -heappop(lheap)

                heappush(rheap, mov)

                heappush(lheap, -a)

                heappush(lheap, -a)

                lsum += a*2 - mov

                rsum += mov

            elif rheap[0] < a:

                mov = heappop(rheap)

                heappush(lheap, -mov)

                heappush(rheap, a)

                heappush(rheap, a)

                lsum += mov

                rsum += a*2 - mov

        else:

            # inquiry

            x = -lheap[0]

            minimum = abs(x * len(lheap) - lsum) // 2 + \

                abs(x * len(rheap) - rsum) // 2 + y

            print(x, minimum)





if __name__ == "__main__":

    main()

from heapq import heappop, heappush


def main():
    Q = int(input())
    y = 0
    lheap = []
    rheap = []
    lsum = 0
    rsum = 0
    for _ in range(Q):
        q = input()
        if q[0] == "1":
            # update
            _, a, b = map(int, q.split())
            y += b
            if len(lheap) == 0 or -lheap[0] <= a <= rheap[0]:
                heappush(lheap, -a)
                heappush(rheap, a)
                lsum += a
                rsum += a
            elif a < -lheap[0]:
                mov = -heappop(lheap)
                heappush(rheap, mov)
                heappush(lheap, -a)
                heappush(lheap, -a)
                lsum += a * 2 - mov
                rsum += mov
            elif rheap[0] < a:
                mov = heappop(rheap)
                heappush(lheap, -mov)
                heappush(rheap, a)
                heappush(rheap, a)
                lsum += mov
                rsum += a * 2 - mov
        else:
            # inquiry
            x = -lheap[0]
            minimum = (
                abs(x * len(lheap) - lsum) // 2 + abs(x * len(rheap) - rsum) // 2 + y
            )
            print(x, minimum)


if __name__ == "__main__":
    main()

from heapq import heappop, heappush
import sys

input = sys.stdin.readline


def main():
    Q = int(input())
    y = 0
    lheap = []
    rheap = []
    lsum = 0
    rsum = 0
    for _ in range(Q):
        q = input()
        if q[0] == "1":
            # update
            _, a, b = map(int, q.split())
            y += b
            if len(lheap) == 0 or -lheap[0] <= a <= rheap[0]:
                heappush(lheap, -a)
                heappush(rheap, a)
                lsum += a
                rsum += a
            elif a < -lheap[0]:
                mov = -heappop(lheap)
                heappush(rheap, mov)
                heappush(lheap, -a)
                heappush(lheap, -a)
                lsum += a * 2 - mov
                rsum += mov
            elif rheap[0] < a:
                mov = heappop(rheap)
                heappush(lheap, -mov)
                heappush(rheap, a)
                heappush(rheap, a)
                lsum += mov
                rsum += a * 2 - mov
        else:
            # inquiry
            x = -lheap[0]
            minimum = (
                abs(x * len(lheap) - lsum) // 2 + abs(x * len(rheap) - rsum) // 2 + y
            )
            print(x, minimum)


if __name__ == "__main__":
    main()

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