#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
int main()
{
    priority_queue <int> q;
    priority_queue < int,vector<int>,greater<int> >Q;
    int n,t;
    long long s=0;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>t;
        if(t==1)
        {
            int a,b;
            cin>>a>>b;
            s+=b;
            q.push(a),Q.push(a);
            int x=q.top(),y=Q.top();
            if(x>y)
            {
                q.pop(),Q.pop();
                s=s+x-y;
                q.push(y),Q.push(x);
            }
        }
        else  cout<<q.top()<<" "<<s<<endl;
    }
    return 0;
}
