#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

class query {
public:
    int type;
    int a, b;
    query(int tin, int ain, int bin) {
        type = tin;
        a = ain;
        b = bin;
    }
};

signed main() {
    int Q;
    cin >> Q;
    vector<query> queries;
    rep(i, Q) {
        int t, a = -1, b = -1;
        cin >> t;

        if (t == 1) {
            cin >> a >> b;
        }

        queries.emplace_back(t, a, b);
    }
    priority_queue<int> smaller;    //中央値 イカ
    priority_queue<int, vector<int>, greater<int>> bigger;  //bigger は小さい順に取り出したい
    int SSum = 0, BSum = 0, constantsSum = 0;

    //奇数の場合はSmallerに寄せる(簡単のため) -> smaller のtop がつねに中央値
    rep(i, Q) {
        if (queries[i].type == 1) {
            constantsSum += queries[i].b;
            if (smaller.size() > bigger.size()) {
                //bigger にいれる
                int t = smaller.top();
                if (queries[i].a >= t) {
                    bigger.push(queries[i].a);
                    BSum += queries[i].a;
                }
                else {
                    smaller.pop();
                    SSum -= t;
                    smaller.push(queries[i].a);
                    SSum += queries[i].a;
                    bigger.push(t);
                    BSum += t;
                }
            }
            else {
                //smaller にいれる
                if (smaller.empty()) {
                    smaller.push(queries[i].a);
                    SSum += queries[i].a;
                }
                else {
                    int t = bigger.top();
                    if (queries[i].a <= t) {
                        smaller.push(queries[i].a);
                        SSum += queries[i].a;
                    }
                    else {
                        bigger.pop();
                        BSum -= t;
                        bigger.push(queries[i].a);
                        BSum += queries[i].a;
                        smaller.push(t);
                        SSum += t;
                    }
                }
            }
        }
        else {
            int med = smaller.top();
            int ans = BSum - bigger.size() * med + smaller.size() * med - SSum + constantsSum;
            cout << smaller.top() << " " << ans << "\n";
        }

    }
    

    return 0;
}


Measured memory_bytes: 9708