Qs = readlines.drop(1).map{|l| l.split.map(&:to_i)}

l, r = [], []
_, s, t = Qs.shift
l.push(s)
r.push(s)
c = t

def ins(a, x)
  a.insert((a.bsearch_index{|y| y > x} || -1), x, x)
end

Qs.each do |q, a, b|
  if q == 1
    c += b
    case
    when a < l.last
      m = l.pop
      c += m - a
      r.unshift(m)
      ins(l, a)
    when r.first < a
      m = r.shift
      c += a - m
      l.push(m)
      ins(r, a)
    else
      l.push(a)
      r.unshift(a)
    end
  else
    puts "#{l.last} #{c}"
  end
end