#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#include <vector>

namespace niu {

  /* 
   *
   * ---- Segment Tree ----
   *
   * Segment Tree can do the following operation
   *  - accumulate the elements in any range of array in time O(logN)
   *  - update the value of element in time O(logN)
   * 
   * ====> template argments <====
   * 
   * Monoid
   *  required -> 
   *   + static Monoid::operation(Monoid, Monoid) -> Monoid
   *   + static Monoid::identity()                -> Monoid
   *
   * ====> member types <====
   *
   *  + size_type       | std::size_t
   *  + value_type      | Monoid
   *  + const_reference | ontainer_type::const_reference
   *
   * ====> member functions <====
   *
   *  * N = the number of elements
   *
   *  + update(const size_type idx, value_type val)
   *   - change the value of the idx-th elements to "val"
   *   - in time O(logN)
   *  + at(const size_type idx)
   *   - access the idx-th element
   *   - in time O(1)
   *  + accumulate(size_type left, size_type right)
   *   - accumulate the elements in [left, right)
   *   - in time O(logN)
   *
   */

  template<class Monoid>
  class segment_tree {

  public:
    using value_type = Monoid;

  private:
    using container_type = std::vector<value_type>;

  public:
    using const_reference = typename container_type::const_reference;
    using size_type = std::size_t;

  protected: 

    container_type node;
    size_type size_;

    static size_type pow_bound(const size_type size) {
      size_type p = 1;
      while(p < size) p <<= 1;
      return p;
    }

    void fix(const size_type idx) {
      node[idx] = value_type::operation(node[idx << 1], node[idx << 1 | 1]);
    }

  public:

    segment_tree(): node() {}
    segment_tree(const size_type size): size_(pow_bound(size)), node(pow_bound(size) << 1, value_type::identity()) {}

    void update(size_type idx, value_type val) {
      assert(idx < size_);
      node[idx += size_] = std::move(val);
      while(idx >>= 1) fix(idx);
    }

    const_reference at(const size_type idx) const {
      assert(idx < size_);
      return node[idx + size_];
    }

    value_type accumulate(size_type left, size_type right) const {
      assert(left <= node.size());
      assert(right <= node.size());
      value_type lf = value_type::identity();
      value_type rf = value_type::identity();
      for(left += size_, right += size_; left < right; left >>= 1, right >>= 1) {
        if(left & 1) lf = value_type::operation(std::move(lf), node[left++]);
        if(right & 1) rf = value_type::operation(node[right - 1], std::move(rf));
      }
      return value_type::operation(std::move(lf), std::move(rf));
    }

    size_type search(i64 s, size_type k = 1, size_type l = 0, size_type r = 0) {
      if(r == 0) r = size_;
      if(l + 1 == r) return l;
      if(node[k << 1].val <= s) {
        return search(s - node[k << 1].val, (k << 1) + 1, (l + r) / 2, r);
      }
      else 
        return search(s, (k << 1), l, (l + r) / 2);
    }
  };

}


struct sm {
  long long val;
  sm(long long val): val(val) {}
  static sm identity() { return sm(0); }
  static sm operation(sm a, sm b) { return sm(a.val + b.val); }
};

using namespace niu;

int main() {
  i64 Q;
  cin >> Q;
  vector<pair<i64,i64>> vec;
  vector<i64> A;
  for(int i = 0;i < Q;i++) {
    int q;
    cin >> q;
    if( q== 1 ) {
      i64 a, b;
      cin >> a >> b;
      vec.push_back({a, b});
      A.push_back(a);
    }
    else {
      vec.push_back({-1, -1});
    }
  }
  sort(all(A));
  segment_tree<sm> s1(A.size()), s2(A.size());
  vector<i64> cnt(A.size());
  i64 B = 0;
  for(auto p: vec) {
    if(p.first == -1) {
      i64 len = s2.accumulate(0, A.size()).val;
      i64 idx = s2.search((len - 1) / 2);
      i64 x = A[idx];
      i64 sum1 = s1.accumulate(0, idx).val;
      i64 len1 = s2.accumulate(0, idx).val;
      i64 sum2 = s1.accumulate(idx, A.size()).val;
      i64 len2 = s2.accumulate(idx, A.size()).val;
      i64 sum = x * (len1)- sum1 + sum2 - x * (len2);
      cout << x << " " << sum + B << endl;
    }
    else {
      i64 a = p.first;
      i64 i = lower_bound(all(A), a) - begin(A);
      cnt[i]++;
      i += cnt[i] - 1;
      s1.update(i, sm(a));
      s2.update(i, sm(1));
      B += p.second;
    }
  }
}


Measured memory_bytes: 15212