#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_Q = 200000; 
int Q;

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

const int MAX_N = MAX_Q+10;

// nを初期化するのを忘れずに
ll n;
ll BIT1[MAX_N+1], BIT2[MAX_N+1];

ll sum(ll i, ll *BIT) {
  ll res = 0;
  while (i > 0) {
    res += BIT[i];
    i -= i & (-i);
  }
  return res;
}


void add(ll i, ll x, ll *BIT) {
  while (i <= n) {
    BIT[i] += x;
    i += i & (-i);
  }
}

int binarySearch(int m, ll *BIT = BIT1) {
    int lb = 0, ub = n, mid;
    while ((ub-lb)>1) {
        mid = (lb+ub)/2;
        ll s = sum(mid, BIT);
        if (s < m) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    return ub;
}

void update(ll a, int idx) {
    add(idx+1, 1, BIT1);
    add(idx+1, a, BIT2);
}

void write(ll k, vector<Pll>& vp, ll sumB) {
    ll m = (k+1)/2;
    cerr << "k: " << k << ", m: " << m << endl;
    int idx = binarySearch(m);
    cerr << "idx: " << idx << endl;

    ll median = vp[idx-1].fi;
    cout << median << ' ';

    ll ans = sum(n, BIT2) + (2*m-k)*median; 
    ans -= 2*sum(idx, BIT2);
    ans += sumB;

    cout << ans << endl;
}

int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);

  cin >> Q;
  vector<Query> vq;
  rep(i, Q) {
      int type;
      cin >> type;
      if (type == 1) {
          int a, b;
          cin >> a >> b;
          vq.push_back((Query){type, a, b});
      } else {
          vq.push_back(Query{type, 0, 0});
      }
  }

  vector<ll> A, B;
  for (int i = 0; i < len(vq); ++i) {
      if (vq[i].type == 1) {
          A.push_back(vq[i].a);
          B.push_back(vq[i].b);
      }
  }

  vector<Pll> vp;
  for (int i = 0; i < len(A); ++i) {
      vp.push_back(Pll(A[i], i));
  }
  sort(all(vp));

  map<int, int> id;
  for (int i = 0; i < len(vp); ++i) {
      id[vp[i].sc] = i;
  }

  n = len(vp);
  ll sumB = 0;
  int idx = 0;
  for (int i = 0; i < len(vq); ++i) {
      if (vq[i].type == 1) {
          update(vp[id[idx]].fi, id[idx]);
          sumB += B[idx];
          ++idx;
      } else {
          write(idx, vp, sumB);
      }
  }

  return 0;
}


Measured memory_bytes: 22252