#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q;
    cin >> Q;
    vector<vector<int>> qs(Q, vector<int>(3, 0));
    REP(i, Q) {
        cin >> qs[i][0];
        if (qs[i][0] == 1) {
            cin >> qs[i][1] >> qs[i][2];
        }
    }

    multiset<int> lset, rset;
    ll lsum = 0, rsum = 0, B = 0;
    int cnt = 0;
    REP(i, Q) {
        if (qs[i][0] == 2) {
            int x = *(--lset.end());
            ll res = rsum - lsum + B;
            if (cnt % 2 == 1) {
                res += x;
            }
            cout << x << " " << res << endl;
            continue;
        }
        int a = qs[i][1];
        B += qs[i][2];
        if (cnt == 0) {
            lsum += a;
            lset.insert(a);
        } else if (cnt % 2 == 0) {
            auto itr = rset.begin();
            if (a <= *itr) {
                lsum += a;
                lset.insert(a);
            } else {
                lsum += *itr;
                rsum += a - *itr;
                lset.insert(*itr);
                rset.insert(a);
                rset.erase(itr);
            }
        } else {
            auto itr = --lset.end();
            if (a >= *itr) {
                rsum += a;
                rset.insert(a);
            } else {
                lsum += a - *itr;
                rsum += *itr;
                rset.insert(*itr);
                lset.insert(a);
                lset.erase(itr);
            }
        }
        cnt++;
    }
    return 0;
}


Measured memory_bytes: 20608