#include <bits/stdc++.h>

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class VAL> struct RBST {
  VAL SUM_UNITY = 0; // to be set

  unsigned int randInt() {
    static unsigned int tx = 123456789, ty = 362436069, tz = 521288629,
                        tw = 88675123;
    unsigned int tt = (tx ^ (tx << 11));
    tx = ty;
    ty = tz;
    tz = tw;
    return (tw = (tw ^ (tw >> 19)) ^ (tt ^ (tt >> 8)));
  }

  struct NODE {
    NODE *left, *right;
    VAL val;  // the value of the node
    int size; // the size of the subtree
    VAL sum;  // the value-sum of the subtree

    NODE() : val(SUM_UNITY), size(1), sum(SUM_UNITY) { left = right = NULL; }

    NODE(VAL v) : val(v), size(1), sum(v) { left = right = NULL; }

    /* additional update */
    inline void update() {}

    /* additional lazy-propagation */
    inline void push() {

      /* ex: reverse */
      /*
      if (this->rev) {
      swap(this->left, this->right);
      if (this->left) this->left->rev ^= true;
      if (this->right) this->right->rev ^= true;
      this->rev = false;
      }
      */
    }
  };

  ///////////////////////
  // root
  ///////////////////////

  NODE *root;
  RBST() : root(NULL) {}
  RBST(NODE *node) : root(node) {}

  ///////////////////////
  // basic operations
  ///////////////////////

  /* size */
  inline int size(NODE *node) { return !node ? 0 : node->size; }
  inline int size() { return this->size(this->root); }

  /* sum */
  inline VAL sum(NODE *node) { return !node ? SUM_UNITY : node->sum; }
  inline VAL sum() { return this->sum(this->root); }

  /* update, push */
  inline NODE *update(NODE *node) {
    node->size = size(node->left) + size(node->right) + 1;
    node->sum = sum(node->left) + sum(node->right) + node->val;
    node->update();
    return node;
  }

  inline void push(NODE *node) {
    if (!node)
      return;
    node->push();
  }

  /* lower_bound */
  inline int lowerBound(NODE *node, VAL val) {
    push(node);
    if (!node)
      return 0;
    if (val <= node->val)
      return lowerBound(node->left, val);
    else
      return size(node->left) + lowerBound(node->right, val) + 1;
  }
  inline int lowerBound(VAL val) { return this->lowerBound(this->root, val); }

  /* upper_bound */
  inline int upperBound(NODE *node, VAL val) {
    push(node);
    if (!node)
      return 0;
    if (val >= node->val)
      return size(node->left) + upperBound(node->right, val) + 1;
    else
      return upperBound(node->left, val);
  }
  inline int upperBound(VAL val) { return this->upperBound(this->root, val); }

  /* count */
  inline int count(VAL val) { return upperBound(val) - lowerBound(val); }

  /* get --- k: 0-index */
  inline VAL get(NODE *node, int k) {
    push(node);
    if (!node)
      return -1;
    if (k == size(node->left))
      return node->val;
    if (k < size(node->left))
      return get(node->left, k);
    else
      return get(node->right, k - size(node->left) - 1);
  }
  inline VAL get(int k) { return get(this->root, k); }

  ///////////////////////
  // merge-split
  ///////////////////////

  NODE *merge(NODE *left, NODE *right) {
    push(left);
    push(right);
    if (!left || !right) {
      if (left)
        return left;
      else
        return right;
    }
    if (randInt() % (left->size + right->size) < left->size) {
      left->right = merge(left->right, right);
      return update(left);
    } else {
      right->left = merge(left, right->left);
      return update(right);
    }
  }
  void merge(RBST add) { this->root = this->merge(this->root, add.root); }
  pair<NODE *, NODE *> split(NODE *node, int k) { // [0, k), [k, n)
    push(node);
    if (!node)
      return make_pair(node, node);
    if (k <= size(node->left)) {
      pair<NODE *, NODE *> sub = split(node->left, k);
      node->left = sub.second;
      return make_pair(sub.first, update(node));
    } else {
      pair<NODE *, NODE *> sub = split(node->right, k - size(node->left) - 1);
      node->right = sub.first;
      return make_pair(update(node), sub.second);
    }
  }
  RBST split(int k) {
    pair<NODE *, NODE *> sub = split(this->root, k);
    this->root = sub.first;
    return RBST(sub.second);
  }

  ///////////////////////
  // insert-erase
  ///////////////////////

  void insert(const VAL val) {
    pair<NODE *, NODE *> sub = this->split(this->root, this->lowerBound(val));
    this->root = this->merge(this->merge(sub.first, new NODE(val)), sub.second);
  }

  void erase(const VAL val) {
    if (!this->count(val))
      return;
    pair<NODE *, NODE *> sub = this->split(this->root, this->lowerBound(val));
    this->root = this->merge(sub.first, this->split(sub.second, 1).second);
  }

  ///////////////////////
  // debug
  ///////////////////////

  void print(NODE *node) {
    if (!node)
      return;
    push(node);
    print(node->left);
    cout << node->val << " ";
    print(node->right);
  }
  void print() {
    cout << "{";
    print(this->root);
    cout << "}" << endl;
  }
};

struct Query {
  int t;
  int a, b;
};

template <typename Monoid> struct SegmentTree {
  using F = function<Monoid(Monoid, Monoid)>;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid e;

  SegmentTree(int n, const F f, const Monoid &e) : f(f), e(e) {
    sz = 1;
    while (sz < n)
      sz <<= 1;
    seg.assign(2 * sz, e);
  }
  // k:=[0,sz)
  void set(int k, const Monoid &x) { seg[k + sz] = x; }

  void build() {
    for (int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
  // k:=[0,sz)
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
  // [a,b)
  Monoid query(int a, int b) {
    Monoid L = e, R = e;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1)
        L = f(L, seg[a++]);
      if (b & 1)
        R = f(seg[--b], R);
    }
    return f(L, R);
  }
  // k:=[0,sz)
  const Monoid &operator[](const int &k) const { return seg[k + sz]; }
  Monoid &operator[](const int &k) { return seg[k + sz]; }
};

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int Q;
  cin >> Q;
  vector<Query> qs(Q);
  vector<int> aa;
  rep(i, 0, Q) {
    int q;
    cin >> q;
    qs[i].t = q;
    if (q == 1) {
      int a, b;
      cin >> a >> b;
      qs[i].a = a;
      qs[i].b = b;
      aa.eb(a);
    }
  }
  sort(all(aa));
  SegmentTree<int> seg(aa.size(), [](int x, int y) { return x + y; }, 0);
  SegmentTree<int> teg(aa.size(), [](int x, int y) { return x + y; }, 0);

  RBST<int> rbst;
  int B = 0;
  rep(i, 0, Q) {
    int q = qs[i].t;

    if (q == 1) {
      int a, b;
      a = qs[i].a;
      b = qs[i].b;
      B += b;
      rbst.insert(a);
      int idx = lower_bound(all(aa), a) - aa.begin();
      seg.update(idx, a + seg[idx]);
      teg.update(idx, 1 + teg[idx]);

    } else {
      int x;
      if (rbst.size() % 2 == 1)
        x = rbst.get(rbst.size() / 2);
      else
        x = rbst.get(rbst.size() / 2 - 1);
      int idx = lower_bound(all(aa), x) - aa.begin();
      int n = seg.query(idx + 1, aa.size()) - teg.query(idx + 1, aa.size()) * x;
      int m = teg.query(0, idx) * x - seg.query(0, idx);

      cout << x << " " << n + m + B << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 24048