#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class I>
class SegmentTree {
 public:
  using Op = function<I(const I&, const I&)>;

 private:
  int n;
  vector<I> dat;
  Op op;
  I e;

 public:
  SegmentTree(int n_, const Op& op, const I& e)
      : op(op), e(e) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, e);
  }
  SegmentTree(const vector<I>& init, const Op& op, const I& e)
      : SegmentTree(init.size(), op, e) {
    for (int i = 0; i < init.size(); i++) {
      dat[i + n - 1] = init[i];
    }
    for (int i = n - 2; i >= 0; i--) {
      dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  const I& operator[](int k) const {
    return dat[k + n - 1];
  }
  void update(int k, const I& a) {
    k += n - 1;
    dat[k] = op(dat[k], a);
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  // [a, b)
  I query(int a, int b) const {
    a += n - 1;
    b += n - 1;
    I vl = e;
    I vr = e;
    while (a < b) {
      if ((a & 1) == 0) vl = op(vl, dat[a]);
      if ((b & 1) == 0) vr = op(dat[b - 1], vr);
      a = a / 2;
      b = (b - 1) / 2;
    }
    return op(vl, vr);
  }
  // query(0, i) >= x となる最小のi
  int kth(const I& x) const {
    int k = 0;
    I v = e;
    while (k < n - 1) {
      I t = op(v, dat[k * 2 + 1]);
      if (x <= t) {
        k = k * 2 + 1;
      } else {
        v = t;
        k = k * 2 + 2;
      }
    }
    return k - (n - 1) + 1;
  }
};

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int Q;
  while (cin >> Q) {
    vector<int> a, b;
    vector<int> ansQuery;
    for (int i = 0; i < Q; i++) {
      int ty;
      cin >> ty;
      if (ty == 1) {
        int qa, qb;
        cin >> qa >> qb;
        a.push_back(qa);
        b.push_back(qb);
      } else {
        ansQuery.push_back(a.size());
      }
    }
    map<int, int> mp;
    for (int x : a) mp[x] = 0;
    vector<int> rawA;
    for (auto& entry : mp) {
      entry.snd = rawA.size();
      rawA.push_back(entry.fst);
    }
    SegmentTree<int> segCnt(rawA.size(), [&](int a, int b) { return a + b; }, 0);
    SegmentTree<ll> segSum(rawA.size(), [&](ll a, ll b) { return a + b; }, 0ll);
    int i = 0;
    ll cons = 0;
    for (int sz : ansQuery) {
      for (; i < sz; i++) {
        segCnt.update(mp[a[i]], 1);
        segSum.update(mp[a[i]], a[i]);
        cons += b[i];
      }
      if (sz == 0) {
        cout << 0 << endl;
      } else {
        int k = segCnt.kth((sz + 1) / 2) - 1;
        ll x = rawA[k];
        ll res = 0;
        res += x * segCnt.query(0, k);
        res -= segSum.query(0, k);
        res += segSum.query(k + 1, rawA.size());
        res -= x * segCnt.query(k + 1, rawA.size());
        res += cons;
        cout << x << " " << res << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 12080