#include <bits/stdc++.h>
using namespace std;

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


int main() {
    cout<<fixed<<setprecision(10);

    ll q; cin>>q;
    vector<pair<ll, pint>> query(q);
    set<ll> st;
    map<ll,ll> z;
    rep(i,q){
        ll t,a,b;
        cin>>t;
        if(t==1){
            cin>>a>>b;
            query[i] = mp(t, mp(a,b));
            st.insert(a);
        }else{
            query[i] = mp(t, mp(0,0));
        }
    }

    // 座圧
    ll cnt = 0;
    for(auto e:st) {
        z[e] = cnt;
        cnt++;
    }

    priority_queue<ll> left;
    priority_queue<ll, vint, greater<ll>> right;
    BinaryIndexedTree<ll> bit(st.size()+2);
    BinaryIndexedTree<ll> bit2(st.size()+2);
    ll b_sum = 0;
    cnt = 0;

    rep(i,q){
        ll t,a,b;
        t = query[i].first;
        tie(a,b) = query[i].second;
        if(t == 1){
            cnt++;
            b_sum += b;
            bit.add(z[a]+1, a);
            bit2.add(z[a]+1, 1);
            if(left.size() == right.size()){
                right.push(a);
                left.push(right.top());
                right.pop();
            }else{ // left.size() > right.size()
                right.push(a);
                left.push(right.top());
                right.pop();
                right.push(left.top());
                left.pop();
            }
        }else{
            ll median = left.top();
            // cout<<bit.sum(z[median])<<" : "<<bit.sum(z[median]+1)<<" "<<bit.sum(st.size()+1)<<" "<<b_sum<<endl;
            ll gx = -bit.sum(z[median]) + (bit.sum(st.size()+1) - bit.sum(z[median]+1)) + b_sum;
            ll num = (bit2.sum(z[median]) - (bit2.sum(st.size()+1) - bit2.sum(z[median]+1)));
            // cout<<num<<endl;
            gx += median*num;
            cout<<median<<" "<<gx<<endl;
        }
    }


    return 0;

}

Measured memory_bytes: 20644