#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

template <class T> struct avl_tree {
    struct node {
        T key;
        int size, height;
        node *child[2];
        node(const T &key) : key(key), size(1), height(1) {
            child[0] = child[1] = 0;
        }
    } * root;
    typedef node *pointer;
    avl_tree() {
        root = NULL;
    }

    pointer find(const T &key) {
        return find(root, key);
    }
    node *find(node *t, const T &key) {
        if(t == NULL) return NULL;
        if(key == t->key)
            return t;
        else if(key < t->key)
            return find(t->child[0], key);
        else
            return find(t->child[1], key);
    }
    void insert(const T &key) {
        root = insert(root, new node(key));
    }
    node *insert(node *t, node *x) {
        if(t == NULL) return x;
        if(x->key <= t->key)
            t->child[0] = insert(t->child[0], x);
        else
            t->child[1] = insert(t->child[1], x);
        t->size += 1;
        return balance(t);
    }
    void erase(const T &key) {
        root = erase(root, key);
    }
    node *erase(node *t, const T &x) {
        if(t == NULL) return NULL;
        if(x == t->key) {
            return move_down(t->child[0], t->child[1]);
        } else {
            if(x < t->key)
                t->child[0] = erase(t->child[0], x);
            else
                t->child[1] = erase(t->child[1], x);
            t->size -= 1;
            return balance(t);
        }
    }
    node *move_down(node *t, node *rhs) {
        if(t == NULL) return rhs;
        t->child[1] = move_down(t->child[1], rhs);
        return balance(t);
    }
#define sz(t) (t ? t->size : 0)
#define ht(t) (t ? t->height : 0)
    node *rotate(node *t, int l, int r) {
        node *s = t->child[r];
        t->child[r] = s->child[l];
        s->child[l] = balance(t);
        if(t) t->size = sz(t->child[0]) + sz(t->child[1]) + 1;
        if(s) s->size = sz(s->child[0]) + sz(s->child[1]) + 1;
        return balance(s);
    }
    node *balance(node *t) {
        for(int i = 0; i < 2; ++i) {
            if(ht(t->child[!i]) - ht(t->child[i]) < -1) {
                if(ht(t->child[i]->child[!i]) - ht(t->child[i]->child[i]) > 0)
                    t->child[i] = rotate(t->child[i], i, !i);
                return rotate(t, !i, i);
            }
        }
        if(t) t->height = max(ht(t->child[0]), ht(t->child[1])) + 1;
        if(t) t->size = sz(t->child[0]) + sz(t->child[1]) + 1;
        return t;
    }
    pointer rank(int k) const {
        return rank(root, k);
    }
    pointer rank(node *t, int k) const {
        if(!t) return NULL;
        int m = sz(t->child[0]);
        if(k < m) return rank(t->child[0], k);
        if(k == m) return t;
        if(k > m) return rank(t->child[1], k - m - 1);
    }
};

struct BinaryIndexedTree {
    vector<vector<long long>> BIT;
    BinaryIndexedTree(vector<long long> A) : BIT() {
        int n;
        while((1 << n) <= A.size()) n++;
        BIT.resize(n);
        while(A.size() < (1 << n) - 1) A.push_back(0);
        for(int i = 0; i < n; i++) BIT[i].resize(1 << (n - i - 1));
        for(int i = 1; i < A.size(); i++) A[i] += A[i - 1];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < BIT[i].size(); j++) {
                BIT[i][j] = A[(1 << (i)) - 1 + (1 << (i + 1)) * j] -
                            (j ? A[(1 << (i + 1)) * j - 1] : 0);
            }
        }
    }
    long long get(long long i) {
        long long ans = 0;
        long long n = 0;
        while(n < BIT.size()) {
            if(i % 2 == 0) {
                ans += BIT[n][(i >> 1)];
                i--;
            }
            i >>= 1;
            n++;
        }
        return ans;
    }
    long long getSum(long long x, long long y) {
        if(y < x) return 0;
        return get(y) - (x ? get(x - 1) : 0);
    }
    void add(long long i, long long x) {
        long long n = 0;
        while(n < BIT.size()) {
            if(i % 2 == 0) {
                BIT[n][(i >> 1)] += x;
            }
            i >>= 1;
            n++;
        }
    }
};

/* main */

signed main() {
    ll N;
    cin >> N;
    vl query(N);
    vl a(N), b(N);
    set<ll> s;
    FOR(i, 0, N) {
        cin >> query[i];
        if(query[i] == 1) {
            cin >> a[i] >> b[i];
            s.insert(a[i]);
        }
    }
    ll idx = 0;
    map<ll, ll> m;
    for(auto x : s) {
        m[x] = idx;
        idx += 1;
    }
    vector<ll> data(s.size(), 0);
    avl_tree<ll> avl;
    BinaryIndexedTree BIT(data), counter(data);
    ll acounter = 0;
    ll bsum = 0;
    FOR(i, 0, N) {
        if(query[i] == 1) {
            BIT.add(m[a[i]], a[i]);
            acounter += 1;
            counter.add(m[a[i]], 1);
            avl.insert(a[i]);
            bsum += b[i];
        }
        if(query[i] == 2) {
            auto p = *avl.rank((acounter - 1) / 2);
            ll x = p.key;
            ll index = m[x];
            ll lower = counter.get(index);
            ll upper = acounter - lower;
            ll MIN = (lower * x - BIT.getSum(0, index));
            if(index + 1 < s.size())
                MIN += (BIT.getSum(index + 1, s.size() - 1) - upper * x);
            cout << x << ' ' << MIN + bsum << endl;
        }
    }
}

Measured memory_bytes: 25708