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
Qs.each do |q, a, b|
  if q == 1
    c += b
    case
    when a < (m = l.pop)
      c += m - a
      r.unshift(m)
      l.push(a)
      l.push(a)
      l.sort!
    when (m = r.shift) < a
      c += a - m
      l.push(m)
      r.push(a)
      r.push(a)
      r.sort!
    else
      l.push(a)
      r.unshift(a)
    end
  else
    puts "#{l.last} #{c}"
  end
end