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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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 Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

struct Query{
    int query, a, b;
    Query() = default;
    Query(int query, int a = -1, int b = -1) : query(query), a(a), b(b) {}
};

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

    int q;
    cin >> q;
    vector<Query> input(q);
    Compress<int> compress;
    for(int i = 0; i < q; ++i){
        int query;
        cin >> query;
        if(query == 1){
            int a, b;
            cin >> a >> b;
            input[i] = Query(query, a, b);
            compress.add(a);
        }
        else    input[i] = Query(query);
    }
    compress.build();
    
    SegmentTree<int> seg(q, [](int a, int b){return a + b;}, 0);
    int median = input[0].a;
    ll res = input[0].b;
    int c = compress.get(median);
    seg.update(c, 1);
    int left_cnt = 0, right_cnt = 0;
    int cnt = 1;
    int median_cnt = 1;
    for(int i = 1; i < q; ++i){
        if(input[i].query == 1){
            int a = input[i].a, b = input[i].b;
            int compressed_a = compress.get(a);
            seg.update(compressed_a, seg[compressed_a] + 1);
            ++cnt;

            int lb = 0, ub = q;
            int comparision = ceil((double)cnt / 2);
            while(ub - lb > 1){
                int mid = (lb + ub) / 2;
                if(seg.query(0, mid) >= comparision)    ub = mid;
                else    lb = mid;
            }

            int now_median = compress[lb];
            if(now_median < median){
                ll dif = median - now_median;
                res += dif * (right_cnt + median_cnt);
                res -= dif * left_cnt;
            }
            else if(now_median > median){
                ll dif = now_median - median;
                res += dif * (left_cnt + median_cnt);
                res -= dif * right_cnt;
            }

            median = now_median;
            res += (ll)abs(median - a) + b;

            median_cnt = seg[lb];
            left_cnt = seg.query(0, lb);
            right_cnt = seg.query(ub, q);
        }

        else{
            cout << median << " " << res << "\n";
        }
    }
}

Measured memory_bytes: 7800