#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, f, a, b;
vector<vector<ll>> q; 
vector<ll> aa;

template<typename T> class segtree {
private:
    int n,sz,h;
    vector<T> node, lazy;
    void eval(int k) {
        if(lazy[k]){
            node[k] += lazy[k];
            if(k < n) {
                lazy[k*2] += lazy[k] / 2, lazy[k*2+1] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()), h(0) {
        while(n < sz) n *= 2, h++;
        node.resize(2*n, 0), lazy.resize(2*n, 0);
        for(int i = 0; i < sz; i++) node[i+n] = v[i];
        for(int i = n-1; i >= 1; i--) node[i] = node[2*i] + node[2*i+1];
    }
    void range(int a, int b, T x, int k=1, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k);
        if(b <= l || r <= a){
            return;
        }
        if(a <= l && r <= b){
            lazy[k] += (r-l)*x;
            eval(k);
        }else{
            range(a, b, x, 2*k, l, (l+r)/2);
            range(a, b, x, 2*k+1, (l+r)/2, r);
            node[k] = node[2*k] + node[2*k+1];
        }
    }
    T query(int a, int b) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        b++;
        T res1 = 0, res2 = 0;
        while(a < b) {
            if(a & 1) eval(a), res1 += node[a++];
            if(b & 1) eval(--b), res2 += node[b];
            a >>= 1, b >>= 1;
        }
        return res1 + res2;
    }
    void _print(){for(int i = 0; i < sz; i++) cout<<query(i,i+1)<< " ";cout<<endl;}
};

struct median_set{
	priority_queue<ll> big, small;
	
	void push(ll x){
		if(small.empty() || x <= small.top()){
			small.push(x);
		}
		else{
			big.push(-x);
		}
		
		if(small.size() > big.size()+1){
			big.push(-small.top());
			small.pop();
		}
		if(small.size() < big.size()){
			small.push(-big.top());
			big.pop();
		}
	}
	
	ll median(){
		return small.top();
	}
	
	ll size(){
		return small.size()+big.size();
	}
};

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	zep(i, 0, n){
		vector<ll> tmp;
		cin >> f;
		tmp.push_back(f);
		if(f == 1){
			cin >> a >> b;
			tmp.push_back(a);
			tmp.push_back(b);
			aa.push_back(a);
		}
		q.push_back(tmp);
	}
	
	sort(aa.begin(), aa.end());
	map<ll, ll> mp;
	zep(i, 0, aa.size()){
		mp[aa[i]] = i;
	}
	ll m = aa.size();
	vector<ll> v(m, 0);
	segtree<ll> sg(v);
	vector<ll> vv(m, 0);
	segtree<ll> sgs(vv);
	
	median_set s;
	a = q[0][1];
	s.push(a);
	sg.range(mp[a], mp[a]+1, q[0][1]);
	sgs.range(mp[a], mp[a]+1, 1);
	ll bb = q[0][2];
	zep(i, 1, n){
		if(q[i][0] == 1){
			a = q[i][1];
			s.push(a);
			sg.range(mp[a], mp[a]+1, q[i][1]);
			sgs.range(mp[a], mp[a]+1, 1);
			bb += q[i][2];
		}
		else{
			ll arg = s.median();
			//print(arg)
			ll ans = arg*sgs.query(0, mp[arg])-sg.query(0, mp[arg])-arg*sgs.query(mp[arg], m)+sg.query(mp[arg], m)+bb;
			//print(ans)
			cout << arg << " " << ans << endl;
			//cout << sgs.query(0, mp[arg]) << sg.query(0, mp[arg]) << sgs.query(mp[arg], m) << sg.query(mp[arg], m) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 35744