local mab, mce, mfl, msq, mmi, mma = math.abs, math.ceil, math.floor, math.sqrt, math.min, math.max

local function lower_bound(ary, x)
  if(x <= ary[1]) then return 1 end
  local num = #ary
  if(ary[num] < x) then return num + 1 end
  local min, max = 1, num
  while(1 < max - min) do
    local mid = ((min + max) // 2)
    if(ary[mid] < x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local ior = io.input()
local q = ior:read("*n")
local aall = {}
local ball = 0
local z, a, b = ior:read("*n", "*n", "*n")
ball = b

local leftsum = a
local rightsum = 0

table.insert(aall, a)
local cnt = 1
for i = 2, q do
  local t = ior:read("*n")
  if t == 1 then
    local a, b = ior:read("*n", "*n")
    ball = ball + b
    local inspos = lower_bound(aall, a)
    if cnt % 2 == 1 then
      local centerpos = (cnt + 1) // 2
      if centerpos < inspos then
        rightsum = rightsum + a
      else
        leftsum = leftsum + a - aall[centerpos]
        rightsum = rightsum + aall[centerpos]
      end
    else
      local cpos = 1 + cnt // 2
      if cpos < inspos then
        leftsum = leftsum + aall[cpos]
        rightsum = rightsum + a - aall[cpos]
      else
        leftsum = leftsum + a
      end
    end
    table.insert(aall, inspos, a)
    cnt = cnt + 1
  else
    local outpos = (cnt + 1) // 2
    local x = aall[outpos]
    local val = cnt % 2 == 1 and x or 0
    print(x .. " " .. val + rightsum - leftsum + ball)
  end
end
