#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<int>> vv;
typedef pair<int, int> P;

// input
int Q;

ll n;
ll asum, bsum, midsum;
multiset<ll> s;
multiset<ll>::iterator itr;


void input() {
    cin >> Q;
}


void param_init() {
    int q, a, b;
    cin >> q >> a >> b;
    n = 1;
    asum = a;
    bsum = b;
    midsum = a;
    s.insert(a);
    itr = s.find(a);
}


void query1() {
    int a, b;
    cin >> a >> b;
    asum += a;
    bsum += b;
    s.insert(a);
    if (a < *itr) {
        midsum += a;
        if (n % 2 == 1) midsum -= *(itr--);
    } else {
        if (n % 2 == 0) midsum += *(++itr);
    }
    n++;
}


void query2() {
    ll x = *itr;
    ll fx = bsum;
    fx += (n + 1) / 2 * (*itr) - midsum;
    fx += (asum - midsum) - n / 2 * (*itr);
    printf("%ld %ld\n", x, fx);
}



int main() {
    input();
    param_init();
    rep(i, Q - 1) {
        int q;
        cin >> q;
        if (q == 1) query1();
        else query2();
    }
}
