output_description: For each evaluation query, print a line containing the response, in the order
  in which the queries are given.
  
  The response to each evaluation query should be the minimum value of x that
  minimizes f(x), and the minimum value of f(x), in this order, with space in
  between.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      Q
      Query_1
      :
      Query_Q
      
  
  See Sample Input 1 for an example.
attempt: from heapq import heappop, heappush
  
  
  class MedianContainer:
      def __init__(self):
          self._left_q = []
          self._right_q = []
          self._left_sum = 0
          self._right_sum = 0
          self._med1, self._med2 = None, None
          self._med = None
  
      def insert(self, x):
          if not any([self._med, self._med1, self._med2]):  # First insert
              self._med = x
          elif self._med is None and self._med1 is not None and self._med2 is not None:
              if x <= self._med1:
                  heappush(self._left_q, x * (-1))
                  heappush(self._right_q, self._med2)
                  self._left_sum += x
                  self._right_sum += self._med2
                  self._med = self._med1
              elif x >= self._med2:
                  heappush(self._left_q, self._med1 * (-1))
                  heappush(self._right_q, x)
                  self._left_sum += self._med1
                  self._right_sum += x
                  self._med = self._med2
              else:
                  heappush(self._left_q, self._med1 * (-1))
                  heappush(self._right_q, self._med2)
                  self._left_sum += self._med1
                  self._right_sum += self._med2
                  self._med = x
              self._med1, self._med2 = None, None
          else:
              if x <= self._med:
                  heappush(self._left_q, x * (-1))
                  self._med1 = heappop(self._left_q) * (-1)
                  self._left_sum += x
                  self._left_sum -= self._med1
                  self._med2 = self._med
              else:
                  heappush(self._right_q, x)
                  self._right_sum += x
                  self._med1 = self._med
                  self._med2 = heappop(self._right_q)
                  self._right_sum -= self._med2
              self._med = None
  
      def get_med(self):
          if self._med is not None:
              return [self._med]
          else:
              return [self._med1, self._med2]
  
      def get_left_sum(self):
          return self._left_sum
  
      def get_right_sum(self):
          return self._right_sum
  
      def get_half_len(self):
          return len(self._left_q)
  
  
  q = int(input())
  ans = 0
  
  mid_1 = 0
  mid_2 = 0
  mid = 0
  left_q = []
  right_q = []
  left_sum = 0
  right_sum = 0
  const_b = 0
  ansl = []
  
  mc = MedianContainer()
  for _ in range(q):
      row = list(input().split())
      if row[0] == "2":
          half_len = mc.get_half_len()
          meds = mc.get_med()
          if len(meds) == 1:
              left_sum = meds[0] * half_len - mc.get_left_sum()
              right_sum = mc.get_right_sum() - meds[0] * half_len
              ans = left_sum + right_sum + const_b
              ansl.append((meds[0], ans))
          else:
              left_sum = meds[0] * half_len - mc.get_left_sum()
              right_sum = mc.get_right_sum() - meds[0] * half_len
              ans = left_sum + right_sum + (meds[1] - meds[0]) + const_b
              ansl.append((meds[0], ans))
  
      else:
          a, b = int(row[1]), int(row[2])
          const_b += b
          mc.insert(a)
  
  
  for ax, av in ansl:
      print(ax, av)
  
problem_description: Statement
  
  There is a function f(x), which is initially a constant function f(x) = 0.
  
  We will ask you to process Q queries in order. There are two kinds of queries,
  update queries and evaluation queries, as follows:
  
    * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).
    * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.
  
  We can show that the values to be output in an evaluation query are always
  integers, so we ask you to print those values as integers without decimal
  points.
samples: [{"input": "4\n    1 4 2\n    2\n    1 1 -8\n    2", "output": "4 2\n    1 -3\n    \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n    1 -1000000000 1000000000\n    1 -1000000000 1000000000\n    1 -1000000000 1000000000\n    2", "output": "-1000000000 3000000000"}]