#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    ll sa = 0, sb = 0, mid = -1;
    priority_queue<ll> q1;                           //小さい方
    priority_queue<ll, vector<ll>, greater<ll>> q2;  //大きい方
    while(q--) {
        int t;
        cin >> t;
        if(t == 1) {
            ll a, b;
            cin >> a >> b;
            sb += b;
            if(mid == -1) {
                if(q1.empty()) {
                    mid = a;
                    continue;
                }
                if(a <= q2.top()) {
                    q1.push(a);
                    sa -= a;
                    mid = q1.top();
                    sa += mid;
                    q1.pop();
                } else {
                    q2.push(a);
                    sa += a;
                    mid = q2.top();
                    sa -= mid;
                    q2.pop();
                }
            } else {
                if(q1.empty()) {
                    if(a < mid) {
                        q1.push(a);
                        sa -= a;
                        q2.push(mid);
                        sa += mid;
                    } else {
                        q1.push(mid);
                        sa -= mid;
                        q2.push(a);
                        sa += a;
                    }
                } else {
                    if(a <= q2.top()) {
                        q1.push(a);
                        sa -= a;
                    } else {
                        q2.push(a);
                        sa += a;
                    }
                    if(mid <= q2.top()) {
                        q1.push(mid);
                        sa -= mid;
                    } else {
                        q2.push(mid);
                        sa += mid;
                    }
                    while(q1.size() > q2.size()) {
                        ll s = q1.top();
                        q1.pop();
                        sa += 2LL * s;
                        q2.push(s);
                    }
                    while(q1.size() < q2.size()) {
                        ll s = q2.top();
                        q2.pop();
                        sa -= 2LL * s;
                        q1.push(s);
                    }
                }
                mid = -1;
            }
        } else {
            if(mid == -1) {
                cout << q1.top() << " ";
            } else {
                cout << mid << " ";
            }
            cout << sa + sb << endl;
        }
    }
}


Measured memory_bytes: 3828