import heapq

Q = int(eval(input()))

INF = 2 * (10 ** 9)

a1, a2 = [INF], [INF]

asum1 = 0

asum2 = 0

bsum = 0

for i in range(Q):

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

    if query[0] == 3:

        break

    if query[0] == 1:

        a, b = query[1:]

        bsum += b

        if len(a1) == len(a2):

            if -a1[0] > a:

                asum1 += a

                heapq.heappush(a1, -a)

            else:

                asum2 += a

                heapq.heappush(a2, a)

                asum1 += a2[0]

                asum2 -= a2[0]

                heapq.heappush(a1, -heapq.heappop(a2))

        else:

            if a2[0] < a:

                asum2 += a

                heapq.heappush(a2, a)

            else:

                asum1 += a

                heapq.heappush(a1, -a)

                asum2 += -a1[0]

                asum1 -= -a1[0]

                heapq.heappush(a2, -heapq.heappop(a1))

    else:

        m = -a1[0]

        print((m, m * (len(a1) - 1) -

              asum1 + asum2 - m * (len(a2) - 1) + bsum))
import heapq

qq = int(eval(input()))

ans = 0

hq1 = []

hq2 = []

x = 10 ** 10

c = 0

p, q = 0, 0

for _ in range(qq):

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

    if que[0] == 1:

        a, b = que[1:]

        ans += b

        if c % 2 == 0:

            if a <= x:

                heapq.heappush(hq1, -a)

                p += a

            else:

                heapq.heappush(hq2, a)

                q += a

                y = heapq.heappop(hq2)

                q -= y

                heapq.heappush(hq1, -y)

                p += y

        else:

            if a <= x:

                heapq.heappush(hq1, -a)

                p += a

                y = -heapq.heappop(hq1)

                p -= y

                heapq.heappush(hq2, y)

                q += y

            else:

                heapq.heappush(hq2, a)

                q += a

        x = -hq1[0]

        c += 1

    else:

        print((x, q - len(hq2) * x + len(hq1) * x - p + ans))

import heapq

Q = int(eval(input()))
INF = 2 * (10**9)
a1, a2 = [INF], [INF]
asum1 = 0
asum2 = 0
bsum = 0
for i in range(Q):
    query = list(map(int, input().split()))
    if query[0] == 3:
        break
    if query[0] == 1:
        a, b = query[1:]
        bsum += b
        if len(a1) == len(a2):
            if -a1[0] > a:
                asum1 += a
                heapq.heappush(a1, -a)
            else:
                asum2 += a
                heapq.heappush(a2, a)
                asum1 += a2[0]
                asum2 -= a2[0]
                heapq.heappush(a1, -heapq.heappop(a2))
        else:
            if a2[0] < a:
                asum2 += a
                heapq.heappush(a2, a)
            else:
                asum1 += a
                heapq.heappush(a1, -a)
                asum2 += -a1[0]
                asum1 -= -a1[0]
                heapq.heappush(a2, -heapq.heappop(a1))
    else:
        m = -a1[0]
        print((m, m * (len(a1) - 1) - asum1 + asum2 - m * (len(a2) - 1) + bsum))

import heapq

qq = int(eval(input()))
ans = 0
hq1 = []
hq2 = []
x = 10**10
c = 0
p, q = 0, 0
for _ in range(qq):
    que = list(map(int, input().split()))
    if que[0] == 1:
        a, b = que[1:]
        ans += b
        if c % 2 == 0:
            if a <= x:
                heapq.heappush(hq1, -a)
                p += a
            else:
                heapq.heappush(hq2, a)
                q += a
                y = heapq.heappop(hq2)
                q -= y
                heapq.heappush(hq1, -y)
                p += y
        else:
            if a <= x:
                heapq.heappush(hq1, -a)
                p += a
                y = -heapq.heappop(hq1)
                p -= y
                heapq.heappush(hq2, y)
                q += y
            else:
                heapq.heappush(hq2, a)
                q += a
        x = -hq1[0]
        c += 1
    else:
        print((x, q - len(hq2) * x + len(hq1) * x - p + ans))

-Q = int(eval(input())) -INF = 2 * (10**9) -a1, a2 = [INF], [INF] -asum1 = 0 -asum2 = 0 -bsum = 0 -for i in range(Q): -    query = list(map(int, input().split())) -    if query[0] == 3: -        break -    if query[0] == 1: -        a, b = query[1:] -        bsum += b -        if len(a1) == len(a2): -            if -a1[0] > a: -                asum1 += a -                heapq.heappush(a1, -a) +qq = int(eval(input())) +ans = 0 +hq1 = [] +hq2 = [] +x = 10**10 +c = 0 +p, q = 0, 0 +for _ in range(qq): +    que = list(map(int, input().split())) +    if que[0] == 1: +        a, b = que[1:] +        ans += b +        if c % 2 == 0: +            if a <= x: +                heapq.heappush(hq1, -a) +                p += a -                asum2 += a -                heapq.heappush(a2, a) -                asum1 += a2[0] -                asum2 -= a2[0] -                heapq.heappush(a1, -heapq.heappop(a2)) +                heapq.heappush(hq2, a) +                q += a +                y = heapq.heappop(hq2) +                q -= y +                heapq.heappush(hq1, -y) +                p += y -            if a2[0] < a: -                asum2 += a -                heapq.heappush(a2, a) +            if a <= x: +                heapq.heappush(hq1, -a) +                p += a +                y = -heapq.heappop(hq1) +                p -= y +                heapq.heappush(hq2, y) +                q += y -                asum1 += a -                heapq.heappush(a1, -a) -                asum2 += -a1[0] -                asum1 -= -a1[0] -                heapq.heappush(a2, -heapq.heappop(a1)) +                heapq.heappush(hq2, a) +                q += a +        x = -hq1[0] +        c += 1 -        m = -a1[0] -        print((m, m * (len(a1) - 1) - asum1 + asum2 - m * (len(a2) - 1) + bsum)) +        print((x, q - len(hq2) * x + len(hq1) * x - p + ans))