#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename T>
struct Compress{
    vector<T> xs;
    Compress() = default;
    Compress(const vector<T> &vs){
        add(vs);
    }
    Compress(const initializer_list<vector<T>> &vs){
        for(auto &p : vs)   add(p);
    }

    // vs 内の座標をすべて追加
    void add(const vector<T> &vs){
        copy(begin(vs), end(vs), back_inserter(xs));
    }

    void add(const T &x){
        xs.emplace_back(x);
    }
    
    void build(){
        sort(begin(xs), end(xs));
        xs.erase(unique(begin(xs), end(xs)), end(xs));
    }

    // vs 内の座標を座標圧縮したものを返す
    vector<int> get(const vector<T> &vs) const{
        vector<int> ret;
        transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x){
            return lower_bound(begin(xs), end(xs), x) - begin(xs);
        });
        return ret;
    }

    // 座標 x を座標圧縮したものを返す (x が xs 内で何番目にあるかを返す)
    int get(const T &x) const{
        return lower_bound(begin(xs), end(xs), x) - begin(xs);
    }

    // 座標圧縮後の k が示す実際の座標を返す
    const T &operator[](int k) const{
        return xs[k];
    }
};

template<typename T>
struct BinaryIndexedTree{
    vector<T> data;
    int sz;

    BinaryIndexedTree(int n){
        sz = n + 2;
        data.assign(sz, 0);
    }

    void add(int i, T x){
        ++i;
        while(i < sz){
            data[i] += x;
            i += i & -i;
        }
    }

    // [0, i] の区間和
    T sum(int i){
        T res = 0;
        ++i;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }

    // [l, r) の区間和
    T sum(int l, int r){
        return sum(r - 1) - sum(l - 1);
    }

    // val 以上を満たす 0-indexed の位置を返す
    int lower_bound(T val){
        // if(val <= 0)    return -1;
        int res = 0;
        int n = 1;
        while(n < sz)   n <<= 1;
        for(int k = n >> 1; k > 0; k >>= 1){
            if(res + k < sz && data[res + k] < val){
                val -= data[res + k];
                res += k;
            }
        }
        return res;     // 1-indexed であれば、res + 1 を返す
    }
};

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

    int Q;
    cin >> Q;
    vector<tuple<int, int, int>> qs;
    Compress<int> xs;
    for(int i = 0; i < Q; ++i){
        int t;
        cin >> t;
        if(t == 2)  qs.emplace_back(t, 0, 0);
        else{
            int a, b;
            cin >> a >> b;
            xs.add(a);
            qs.emplace_back(t, a, b);
        }
    }
    xs.build();
    int N = xs.xs.size();
    BinaryIndexedTree<int> bit(N);
    int Median = -1;
    ll val = 0;
    for(auto& tup : qs){
        if(get<0>(tup) == 2)    cout << xs[Median] << ' ' << val << '\n';
        else{
            int a = xs.get(get<1>(tup));
            val += get<2>(tup);
            bit.add(a, 1);
            if(Median == -1)    Median = a;
            else{
                int NxtMedian = bit.lower_bound((bit.sum(N) + 1) / 2);
                if(NxtMedian < Median){
                    int d = xs[Median] - xs[NxtMedian];
                    bit.add(a, -1);
                    val -= (ll)d * bit.sum(NxtMedian);
                    val += (ll)d * bit.sum(Median, N);
                    bit.add(a, 1);
                }
                else if(NxtMedian > Median){
                    int d = xs[NxtMedian] - xs[Median];
                    bit.add(a, -1);
                    val += (ll)d * bit.sum(Median);
                    val -= (ll)d * bit.sum(NxtMedian, N);
                    bit.add(a, 1);
                }
                Median = NxtMedian;
                val += abs(xs[Median] - xs[a]);
            }
        }
    }
}

Measured memory_bytes: 7172