#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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 (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

struct BIT {
    //[1, size]
    vector<int> data;
    int size;

    BIT(int s = 0) {
        size = s;
        data.assign(size + 1, 0);
    }

    //sum [1, i]
    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }

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

    // x <= sum(i) を満たす最小のi
    int lower_bound(int x) {
        int ng = -1;
        int ok = size + 1;

        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;

            if (x <= sum(mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
};

struct Query {
    int kind;
    ll a, b;
};

int main() {
    int q;
    cin >> q;

    vector<Query> qs(q);
    rep(i, q) {
        cin >> qs.at(i).kind;
        if (qs.at(i).kind == 1) cin >> qs.at(i).a >> qs.at(i).b;
    }

    vector<ll> as;
    for (const Query &q: qs) {
        if (q.kind == 1) as.push_back(q.a);
    }
    sort(as.begin(), as.end());
    as.erase(unique(as.begin(), as.end()), as.end());

    map<ll, int> compress;
    vector<ll> decompress(200000, -1e10);
    rep(i, as.size()) {
        compress[as.at(i)] = i + 1;
        decompress[i + 1] = as.at(i);
    }

    BIT bit(200000);
    ll sum_abs = 0, sum_b = qs.at(0).b;
    ll comp_median = compress[qs.at(0).a];
    bit.add(compress[qs.at(0).a], 1);
    int cnt_a = 1;
    
    repr(i, 1, q) {
        if (qs.at(i).kind == 1) {
            ll ca = compress[qs.at(i).a];
            cnt_a++;
            
            sum_b += qs.at(i).b;
            ll prev_comp_median = comp_median;
            bit.add(ca, 1);
            comp_median = bit.lower_bound((cnt_a + 1) / 2);
            
            int num_less_than_med = bit.sum(comp_median - 1);
            int num_greater_than_med = cnt_a - bit.sum(comp_median);
            if (ca < comp_median) num_less_than_med--;
            else if (comp_median < ca) num_greater_than_med--;
            
            ll diff = abs(decompress[comp_median] - decompress[prev_comp_median]);
            if (prev_comp_median < comp_median) {
                num_greater_than_med += bit.sum(comp_median) - bit.sum(comp_median - 1);
                if (ca == comp_median) num_greater_than_med--;
                sum_abs += (num_less_than_med - num_greater_than_med) * diff;
            }
            else {
                num_less_than_med += bit.sum(comp_median) - bit.sum(comp_median - 1);
                if (ca == comp_median) num_less_than_med--;
                sum_abs += (num_greater_than_med - num_less_than_med) * diff;
            }
            sum_abs += abs(decompress[comp_median] - qs.at(i).a);
        }
        else printf("%lld %lld\n", decompress[comp_median], sum_abs + sum_b);
    }
}

Measured memory_bytes: 16628