#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

template <typename T>
struct SegmentTree {
    using F = function<T(T, T)>;
    int n;
    vector<T> data;
    T identity;
    F operation;
    SegmentTree(T _identity, F _operation)
        : identity(_identity), operation(_operation){}
    void init(int _n) {
        n = 1;
        while (n < _n) n <<= 1;
        data.assign(n<<1, identity);
    }
    void build(const vector<T> &v) {
        int _n = (int)v.size();
        init(_n);
        for (int i = 0; i < _n; ++i) data[n+i] = v[i];
        for (int i = n-1; i >= 0; --i) {
            data[i] = operation(data[i<<1|0], data[i<<1|1]);
        }    
    }
    T operator[](int i) { return data[n+i];}
    void set(int i, T x) {
        i += n;
        data[i] = x;
        while (i > 1) {
            i >>= 1;
            data[i] = operation(data[i<<1|0], data[i<<1|1]);
        }
    }
    T fold(int l, int r) {
        l += n; r += n;
        T resl = identity, resr = identity;
        while (l < r) {
            if (l & 1) resl = operation(resl, data[l++]);
            if (r & 1) resr = operation(data[--r], resr);
            l >>= 1; r >>= 1;
        }
        return operation(resl, resr);
    }
    template <typename C>
    int find(int st, C &check, T &acc, int i, int l, int r) {
        if (l+1 == r) {
            acc = operation(acc, data[i]);
            return check(acc) ? i-n : -1;
        }
        int m = (l+r)>>1;
        if (m <= st) return find(st, check, acc, i<<1|1, m, r);
        if (st <= l && !check(operation(acc, data[i]))) {
            acc = operation(acc, data[i]);
            return -1;
        }
        int vl = find(st, check, acc, i<<1|0, l, m);
        if (vl != -1) return vl;
        return find(st, check, acc, i<<1|1, m, r);
    }
    // min idx s.t. st <= idx && !check(fold(st, idx-1)) && check(fold(st, idx))
    template <typename C>
    int find(int st, C &check) {
        T acc = identity;
        return find(st, check, acc, 1, 0, n);
    }
};

template <typename T>
struct compress {
    map<T, int> zip;
    vector<T> unzip;
    compress(const vector<T> &v) {
        int n = (int)v.size();
        for (int i = 0; i < n; ++i) zip[v[i]] = 0;
        int num = 0;
        unzip.resize(n);
        for (auto&& p : zip) {
            p.second = num++;
            unzip[p.second] = p.first;
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int q;
    cin >> q;
    vi t(q), a, b;
    rep(i, q) {
        cin >> t[i];
        if (t[i] == 1) {
            int x, y;
            cin >> x >> y;
            a.pb(x);
            b.pb(y);
        }
    }
    compress<int> comp(a);
    auto f = [](ll a, ll b) { return a + b;};
    SegmentTree<ll> segcnt(0, f), segsum(0, f);
    segcnt.init(q); segsum.init(q);
    ll b_sum = 0;
    int cnt = 0;
    int nowidx = 0;
    rep(i, q) {
        if (t[i] == 1) {
            int x = comp.zip[a[nowidx]];
            segcnt.set(x, segcnt[x] + 1);
            segsum.set(x, segsum[x] + a[nowidx]);
            cnt++;
            b_sum += b[nowidx];
            nowidx++;
        } else {
            auto check = [&](int a) { return a >= (cnt+1)/2;};
            int mid = segcnt.find(0, check);
            // cout << mid << endl;
            ll ans = b_sum;
            ans += segcnt.fold(0, mid) * comp.unzip[mid] - segsum.fold(0, mid);
            ans += segsum.fold(mid+1, q+1) - segcnt.fold(mid+1, q+1) * comp.unzip[mid];
            cout << comp.unzip[mid] << " " << ans << endl;
        }
    }
}

Measured memory_bytes: 17524