import heapq



q = int(eval(input()))



nchange = 0

ming, maxg = [], []

heapq.heapify(ming)

heapq.heapify(maxg)

a = 0

b = 0

for i in range(q):

    qi = eval(input())

    if qi[0] == '1':

        _, ai, bi = list(map(int, qi.split()))

        b += bi

        nchange += 1

        if nchange % 2 == 1:

            if nchange == 1:

                x = ai

                continue

            Smax = -heapq.heappop(ming)

            Dmin = heapq.heappop(maxg)

            if Smax <= ai and ai <= Dmin:

                heapq.heappush(ming, -Smax)

                heapq.heappush(maxg, Dmin)

                x = ai

            elif ai < Smax:

                heapq.heappush(ming, -ai)

                heapq.heappush(maxg, Dmin)

                x = Smax

                a += Smax - ai

            else:

                heapq.heappush(ming, -Smax)

                heapq.heappush(maxg, ai)

                x = Dmin

                a += ai - Dmin

        else:

            heapq.heappush(ming, -min(x, ai))

            heapq.heappush(maxg, max(x, ai))

            a += abs(x - ai)

            x = -heapq.heappop(ming)

            heapq.heappush(ming, -x)

    else:

        print((x, a+b))
import heapq



q = int(eval(input()))

ans = []

mini = 0

left, right = [], []

cnt = 0

mid = None

for _ in range(q):

    qi = eval(input())

    if qi == '2':

        if cnt%2 == 0:

            ans.append([-left[0], mini])

        else:

            ans.append([mid, mini])

    else:

        kind, a, b = list(map(int, qi.split()))

        if cnt%2 == 1:

            mini += abs(mid-a) + b

            heapq.heappush(left, -min(mid, a))

            heapq.heappush(right, max(mid, a))

            mid = None

        else:

            if cnt == 0:

                mid = a

                mini = b

                cnt += 1

                continue

            l = -heapq.heappop(left)

            r = heapq.heappop(right)

            if a <= l:

                mini += l-a + b

                heapq.heappush(left, -a)

                heapq.heappush(right, r)

                mid = l

            elif a <= r:

                mini += b

                heapq.heappush(left, -l)

                heapq.heappush(right, r)

                mid = a

            else:

                mini += a-r + b

                heapq.heappush(left, -l)

                heapq.heappush(right, a)

                mid = r

        cnt += 1



for i, j in ans:

    print((i, j))
import heapq

q = int(eval(input()))
nchange = 0
ming, maxg = [], []
heapq.heapify(ming)
heapq.heapify(maxg)
a = 0
b = 0
for i in range(q):
    qi = eval(input())
    if qi[0] == "1":
        _, ai, bi = list(map(int, qi.split()))
        b += bi
        nchange += 1
        if nchange % 2 == 1:
            if nchange == 1:
                x = ai
                continue
            Smax = -heapq.heappop(ming)
            Dmin = heapq.heappop(maxg)
            if Smax <= ai and ai <= Dmin:
                heapq.heappush(ming, -Smax)
                heapq.heappush(maxg, Dmin)
                x = ai
            elif ai < Smax:
                heapq.heappush(ming, -ai)
                heapq.heappush(maxg, Dmin)
                x = Smax
                a += Smax - ai
            else:
                heapq.heappush(ming, -Smax)
                heapq.heappush(maxg, ai)
                x = Dmin
                a += ai - Dmin
        else:
            heapq.heappush(ming, -min(x, ai))
            heapq.heappush(maxg, max(x, ai))
            a += abs(x - ai)
            x = -heapq.heappop(ming)
            heapq.heappush(ming, -x)
    else:
        print((x, a + b))

import heapq

q = int(eval(input()))
ans = []
mini = 0
left, right = [], []
cnt = 0
mid = None
for _ in range(q):
    qi = eval(input())
    if qi == "2":
        if cnt % 2 == 0:
            ans.append([-left[0], mini])
        else:
            ans.append([mid, mini])
    else:
        kind, a, b = list(map(int, qi.split()))
        if cnt % 2 == 1:
            mini += abs(mid - a) + b
            heapq.heappush(left, -min(mid, a))
            heapq.heappush(right, max(mid, a))
            mid = None
        else:
            if cnt == 0:
                mid = a
                mini = b
                cnt += 1
                continue
            l = -heapq.heappop(left)
            r = heapq.heappop(right)
            if a <= l:
                mini += l - a + b
                heapq.heappush(left, -a)
                heapq.heappush(right, r)
                mid = l
            elif a <= r:
                mini += b
                heapq.heappush(left, -l)
                heapq.heappush(right, r)
                mid = a
            else:
                mini += a - r + b
                heapq.heappush(left, -l)
                heapq.heappush(right, a)
                mid = r
        cnt += 1
for i, j in ans:
    print((i, j))

-nchange = 0 -ming, maxg = [], [] -heapq.heapify(ming) -heapq.heapify(maxg) -a = 0 -b = 0 -for i in range(q): +ans = [] +mini = 0 +left, right = [], [] +cnt = 0 +mid = None +for _ in range(q): -    if qi[0] == "1": -        _, ai, bi = list(map(int, qi.split())) -        b += bi -        nchange += 1 -        if nchange % 2 == 1: -            if nchange == 1: -                x = ai +    if qi == "2": +        if cnt % 2 == 0: +            ans.append([-left[0], mini]) +        else: +            ans.append([mid, mini]) +    else: +        kind, a, b = list(map(int, qi.split())) +        if cnt % 2 == 1: +            mini += abs(mid - a) + b +            heapq.heappush(left, -min(mid, a)) +            heapq.heappush(right, max(mid, a)) +            mid = None +        else: +            if cnt == 0: +                mid = a +                mini = b +                cnt += 1 -            Smax = -heapq.heappop(ming) -            Dmin = heapq.heappop(maxg) -            if Smax <= ai and ai <= Dmin: -                heapq.heappush(ming, -Smax) -                heapq.heappush(maxg, Dmin) -                x = ai -            elif ai < Smax: -                heapq.heappush(ming, -ai) -                heapq.heappush(maxg, Dmin) -                x = Smax -                a += Smax - ai +            l = -heapq.heappop(left) +            r = heapq.heappop(right) +            if a <= l: +                mini += l - a + b +                heapq.heappush(left, -a) +                heapq.heappush(right, r) +                mid = l +            elif a <= r: +                mini += b +                heapq.heappush(left, -l) +                heapq.heappush(right, r) +                mid = a -                heapq.heappush(ming, -Smax) -                heapq.heappush(maxg, ai) -                x = Dmin -                a += ai - Dmin -        else: -            heapq.heappush(ming, -min(x, ai)) -            heapq.heappush(maxg, max(x, ai)) -            a += abs(x - ai) -            x = -heapq.heappop(ming) -            heapq.heappush(ming, -x) -    else: -        print((x, a + b)) +                mini += a - r + b +                heapq.heappush(left, -l) +                heapq.heappush(right, a) +                mid = r +        cnt += 1 +for i, j in ans: +    print((i, j))