

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;




int main() {
  ll q;
  cin >> q;
  priority_queue <ll> l;
  priority_queue <ll, vector<ll>, greater <ll>> r;
  ll cnt=0;

  rep(i,q){
    ll Q;
    cin>>Q;

  //  ll ans=0;
    if(Q==1){
      ll a,b;
      cin>>a>>b;
      cnt+=b;
      l.push(a);
      r.push(a);
      ll l1=l.top();
      ll r1=r.top();
      l.pop();r.pop();
      if(l1>r1){
        swap(l1,r1);
        cnt+=abs(l1-r1);


      }
      l.push(l1);
      r.push(r1);
    }

    else if (Q==2){
      cout<<l.top()<<' '<<cnt<<endl;

    }
  }
}
