#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    priority_queue<int> smaller;
    priority_queue<int,vector<int>,greater<int>> bigger;
    int sum = 0;
    int bigsum = 0,smallsum = 0;
    int q;cin >> q;
    while(q--){
        int type;cin >> type;
        if(type == 1){
            int a,b;cin >> a >> b;
            sum += b;
            if(smaller.size() > bigger.size()){
                int tmp = smaller.top();
                if(a >= tmp){
                    bigger.push(a);
                    bigsum += a;
                }
                else {
                    //入れ替え
                    smaller.pop();
                    smallsum -= tmp;
                    smaller.push(a);
                    smallsum += a;
                    bigger.push(tmp);
                    bigsum += tmp;
                }
            }
            else{
                if(smaller.size() == 0){
                    smaller.push(a);
                    smallsum += a;
                    continue;
                }
                int tmp = bigger.top();
                if(a <= tmp){
                    smallsum += a;
                    smaller.push(a);
                }
                else{
                    //入れ替え
                    bigger.pop();
                    bigsum -= tmp;
                    bigger.push(a);
                    bigsum += a;
                    smaller.push(tmp);
                    smallsum += tmp;
                }
            }
        }
        else if(type == 2){
            int x  = smaller.top();
            int ret = (x*(int)smaller.size() - smallsum) + (bigsum - x*(int)bigger.size()) + sum;
            cout << x <<" " << ret << "\n";
            
        }
    }
    return 0;
}

Measured memory_bytes: 5096