from heapq import heappop,heappush

l,r=[],[]

ans=0

for _ in range(int(eval(input()))):

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

	if a[0]==1:

		_,ia,ib=a

		heappush(l,-ia)

		heappush(r,ia)

		ll=heappop(l)

		rr=heappop(r)

		heappush(l,-rr)

		heappush(r,-ll)

		ans+=ib+abs(ll+rr)

	else:print((-l[0],ans))
from heapq import heappop,heappush

q=int(eval(input()))

queries=[list(map(int,input().split()))for _ in range(q)]

l=[]

r=[]

ans=0

queonecount=0

mid=-1

for query in queries:

  if query[0]==1:

    queonecount+=1

    _,a,b=query

    ans+=b

    heappush(l,-a)

    heappush(r,a)

    midl=-heappop(l)

    midr=heappop(r)

    ans+=abs(midl-midr)

    heappush(l,-midr)

    heappush(r,midl)

  if query[0]==2:

    minind=-heappop(l)

    print((minind,ans))

    heappush(l,-minind)
from heapq import heappop, heappush

l, r = [], []
ans = 0
for _ in range(int(eval(input()))):
    a = list(map(int, input().split()))
    if a[0] == 1:
        _, ia, ib = a
        heappush(l, -ia)
        heappush(r, ia)
        ll = heappop(l)
        rr = heappop(r)
        heappush(l, -rr)
        heappush(r, -ll)
        ans += ib + abs(ll + rr)
    else:
        print((-l[0], ans))

from heapq import heappop, heappush

q = int(eval(input()))
queries = [list(map(int, input().split())) for _ in range(q)]
l = []
r = []
ans = 0
queonecount = 0
mid = -1
for query in queries:
    if query[0] == 1:
        queonecount += 1
        _, a, b = query
        ans += b
        heappush(l, -a)
        heappush(r, a)
        midl = -heappop(l)
        midr = heappop(r)
        ans += abs(midl - midr)
        heappush(l, -midr)
        heappush(r, midl)
    if query[0] == 2:
        minind = -heappop(l)
        print((minind, ans))
        heappush(l, -minind)

-l, r = [], [] +q = int(eval(input())) +queries = [list(map(int, input().split())) for _ in range(q)] +l = [] +r = [] -for _ in range(int(eval(input()))): -    a = list(map(int, input().split())) -    if a[0] == 1: -        _, ia, ib = a -        heappush(l, -ia) -        heappush(r, ia) -        ll = heappop(l) -        rr = heappop(r) -        heappush(l, -rr) -        heappush(r, -ll) -        ans += ib + abs(ll + rr) -    else: -        print((-l[0], ans)) +queonecount = 0 +mid = -1 +for query in queries: +    if query[0] == 1: +        queonecount += 1 +        _, a, b = query +        ans += b +        heappush(l, -a) +        heappush(r, a) +        midl = -heappop(l) +        midr = heappop(r) +        ans += abs(midl - midr) +        heappush(l, -midr) +        heappush(r, midl) +    if query[0] == 2: +        minind = -heappop(l) +        print((minind, ans)) +        heappush(l, -minind)