#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
//const int maxN = 2e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 1e9+7;

const int maxN = 200010;
struct node
{
    int val;
    ll sum;
    node *lc,*rc;
    int key;
    int size;
    node () {};
    node(int val,node *lc,node *rc,int key):val(val),lc(lc),rc(rc),key(key)
    {
        size = lc->size + rc->size + 1;
        sum  = (ll)lc->sum + rc->sum + val;
    }
};
typedef pair<node* ,node *> pnn;
int tot;
node nodes[maxN];
//node *nil = nodes;
node *nil;
node *create(int val)
{
    node *it = &nodes[++tot];
    it->val = val;
    it->sum = val;
    it->lc = it->rc = nil;
    it->key = rand();
    it->size = 1;
    return it;
}
struct treap
{
    node *root;
    void init()
    {
        nil = nodes;
        nil->lc = nil->rc = nil;
        nil->size = 0;
        root = nil;
    }
    pnn split(node *x,int k)
    {
        if(x == nil) return pnn(nil,nil);
        if(k == 0) return pnn(nil,x);
        if(x->lc->size >=k)
        {
            pnn d = split(x->lc,k);
            *x = node(x->val,d.second,x->rc,x->key);
            return pnn(d.first,x);
        }
        else
        {
            pnn d = split(x->rc,k - x->lc->size-1);
            * x = node(x->val,x->lc,d.first,x->key);
            return pnn(x,d.second);
        }
    }
    node *merge(node *a,node *b)
    {
        if(a == nil && b == nil) return nil;
        if(a==nil) return b;
        if(b==nil) return a;
        if(a->key < b->key)
        {
            *a = node(a->val,a->lc,merge(a->rc,b),a->key);
            return a;
        }
        else
        {
            *b = node(b->val,merge(a,b->lc),b->rc,b->key);
            return b;
        }
    }
    void insert(int val)
    {
        node *x = root;
        int k = 0;
        while(x != nil)
        {
            //if(x->val == val) return;
            if(x->val > val)
                x = x->lc;
            else
            {
                k+= x->lc->size + 1;
                x = x->rc;
            }
        }
        pnn d = split(root,k);
        root = merge(merge(d.first,create(val)),d.second);
    }
    void erase(int val)
    {
        node *x = root;
        int k = 0;
        int flag = 0;
        while(x != nil)
        {
            if(x->val == val) flag = 1;
            if(x->val >= val) x = x->lc;
            else
            {
                k += x->lc->size + 1;
                x = x->rc;
            }
        }
        if(flag)
        {
            pnn a = split(root,k);
            pnn b = split(a.second,1);
            root = merge(a.first,b.second);
        }
    }
    node *kth(int k)
    {
        node *x = root;
        while(x!= nil)
        {
            if(x->lc->size + 1 == k)
                break;
            if(x->lc->size >= k)
                x = x->lc;
            else
            {
                k -= x->lc->size + 1;
                x = x->rc;
            }
        }
        return x;
    }
    int rank(int val)
    {
        int ret = 0;
        node *x = root;
        while(x!= nil)
        {
            if(x->val >= val)
                x = x->lc;
            else
            {
                ret += x->lc->size + 1;
                x = x->rc;
            }
        }
        return ret;
    }
}T;
int Q;
int main()
{
	scanf("%d",&Q);
	ll bsum=0;
	int cnt = 0;
	T.init();
	for(int i=1;i<=Q;i++)
	{
		int tag;
		scanf("%d",&tag);
		if(tag == 1)
		{
			int x,y;
			scanf("%d %d",&x,&y);
			cnt++;
			bsum += y;
			T.insert(x);
		}
		else
		{
			int g = (cnt+1)/2;
			ll v = T.kth(g)->val;
			pnn ret = T.split(T.root, g);
			ll ans = (v* ret.first->size) - ret.first->sum + (ret.second->sum) - (v*ret.second->size)  + bsum;
			printf("%lld %lld\n",v,ans);
			T.root = T.merge(ret.first, ret.second);
		}
	}
	
	return 0;
}

Measured memory_bytes: 8064