#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

template<typename T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


const int Q = 2e5 + 5;
const int MX = 1e9 + 3;

struct node {
    ll sum , lazy;
    node *left , *right;
    node () : sum(0) , lazy(0) , left(0) , right(0) {};
    ~node() {delete left , delete right;}
};

using nodePtr = node*;

class segTree {
    const int LN = -MX , RN = MX; // can be negative
    nodePtr root;

    ll getSum(nodePtr &a) {
        return a ? a->sum : 0;
    }

    void addSum(nodePtr &a , ll v) {
        if (!a) a = new node();
        a->sum += v;
    }

    void addLazy(nodePtr &a , ll v) {
        if (!a) a = new node();
        a->lazy += v;
    }

    void pushDown(nodePtr &cur , ll l , ll r) {
        if (cur && cur->lazy) {
            cur->sum += cur->lazy * (r - l + 1);
            addLazy(cur->left , cur->lazy);
            addLazy(cur->right , cur->lazy);
            cur->lazy = 0;
        }
    }

    void in (ll i , ll v , nodePtr &cur , ll l , ll r) {
        if (i > r || i < l)
            return;

        addSum(cur , v);
        if (l == r)
            return;

        ll mid = l + (r - l) / 2;
        in(i , v  , cur->left, l , mid);
        in(i , v  ,cur->right , mid + 1 , r);
    }

    ll query (ll s , ll e , nodePtr &cur , ll l , ll r) {
        pushDown(cur , l , r);
        if (!cur || l > e || r < s)
            return 0;
        if (l >= s && r <= e)
            return cur->sum;
        ll mid = l + (r - l) / 2;
        return query(s , e , cur->left , l , mid) + query(s , e , cur->right , mid + 1 , r);
    }

    void update(ll s , ll e , ll v , nodePtr &cur , ll l , ll r) {
        pushDown(cur , l , r);
        if (l > e || r < s)
            return ;

        addSum(cur , 0); // to handle if cur = null

        if (l >= s && r <= e) {
            cur->sum += v * (r - l + 1);
            addLazy(cur->left , v);
            addLazy(cur->right , v);
            return;
        }

        ll mid = l + (r - l) / 2;
        update(s , e , v , cur->left , l , mid);
        update(s , e , v,  cur->right , mid + 1 , r);
        cur->sum = getSum(cur->left) + getSum(cur->right);
    }
public:
    segTree() : root(0) {}
    ~segTree() {delete root;}
    void in(ll i , ll v) {
        in(i , v , root , LN , RN);
    }

    ll query(ll s , ll e) {
        return query(s , e , root , LN , RN);
    }

    void update(ll s , ll e , ll v) {
        update(s , e , v , root , LN , RN);
    }
};





int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    segTree segSum , segCnt;
    Tree<pii> X;
    long long ans = 0;
    int q, a, b, type;
    cin >> q;
    loop(i, q) {
        cin >> type;
        if (type == 1) {
            cin >> a >> b;
            ans += b;
            segSum.in(a,a);
            segCnt.in(a,1);
            X.insert({a, i});
        } else {
            int x = (*X.find_by_order((SZ(X) - 1) / 2)).fr;
            long long cur = ans;
            cur += abs(1LL * segCnt.query(-MX,x-1) * x - segSum.query(-MX,x-1));
            cur += abs(1LL * segCnt.query(x+1,MX) * x - segSum.query(x+1,MX));
            cout << x << " " << cur  << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 153472