#include<bits/stdc++.h>
using namespace std;

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct segmentTree{
    int N;
    vector<long long> sum;
    const long long INF = 2e18;
    
    void init(int siz){
        N = 1;
        while(N < siz){
            N <<= 1;
        }
        sum.resize(N * 2 - 1);
        return;
    }

    void build(vector<long long> &dat){
        init(dat.size());
        for(int i = 0, len = dat.size() ; i < len ; ++i){
            sum[i + N - 1] = dat[i];
        }
        for(int i = N - 2 ; i >= 0 ; --i){
            sum[i] = sum[i * 2 + 1] + sum[i * 2 + 2];
        }
        return;
    }

    void update(int k, long long x){
        k += N - 1;
        sum[k] = x;
        while(k > 0){
            k = (k - 1) / 2;
            sum[k] = sum[k * 2 + 1] + sum[k * 2 + 2];
        }
        return;
    }

    void add(int k, long long x){
        update(k, sum[k + N - 1] + x);
        return;
    }

    long long getSum(int a, int b, int k, int l, int r){
        if(r <= a || b <= l){
            return 0LL;
        }
        if(a <= l && r <= b){
            return sum[k];
        }
        long long vl = getSum(a, b, k * 2 + 1, l, (l + r) / 2);
        long long vr = getSum(a, b, k * 2 + 2, (l + r) / 2, r);
        return vl + vr;
    }

    long long getSum(int a, int b){
        return getSum(a, b, 0, 0, N);
    }

    int lower_bound(long long x){
        int left = 0, right = N;
        while(right - left > 1){
            int mid = (left + right) / 2;
            if(getSum(0, mid) < x){
                left = mid;
            }else{
                right = mid;
            }
        }
        return left;
    }
};

template<typename T>
int compress(vector<T> &v, map<T, int> &zip, vector<T> &unzip){
    sort(v.begin(), v.end());
    unzip.resize(v.size());
    for(int i = 0, i_len = (int)v.size() ; i < i_len ; ++i){
        zip[v[i]] = i;
        unzip[i] = v[i];
    }
    return (int)v.size();
}

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

    int q;
    cin >> q;

    vector< pair< int, LLP > > v(q);
    vector< LLP > x;
    rep(i, q){
        cin >> v[i].first;
        if(v[i].first == 1){
            cin >> v[i].second.first >> v[i].second.second;
            x.push_back(v[i].second);
        }
    }

    map< LLP, int > zip;
    vector< LLP > unzip;
    int n = compress(x, zip, unzip);

    vector<lint> a(n);
    segmentTree seg;
    seg.build(a);
    segmentTree seg2;
    seg2.build(a);

    lint sum = 0, cnt = 0;

    map< LLP, lint > mp;

    rep(i, q){
        if(v[i].first == 1){
            seg.add(zip[v[i].second] - mp[v[i].second], 1LL);
            ++cnt;
            sum += v[i].second.second;
            seg2.add(zip[v[i].second] - mp[v[i].second], v[i].second.first);
            ++mp[v[i].second];
        }else{
            int k = seg.lower_bound((cnt + 1LL) / 2LL);
            cout << unzip[k].first << " ";
            if(cnt % 2LL == 0LL){
                cout << sum - seg2.getSum(0, k + 1) + seg2.getSum(k + 1, n) << endl;
            }else{
                cout << sum - seg2.getSum(0, k) + seg2.getSum(k + 1, n) << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 28016