#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
// const int MOD = 1000000007;
const ll MOD = 1000000007;
// const int MAX=123456;
const ll MAX=99999999999;

const ll INF = 1LL << 60;

// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(int argc, char**argv){
    priority_queue<ll> left;
    priority_queue<ll, vector<ll>, greater<ll> > right;
    ll med = -MAX - 1;  // None

    int nq;
    cin >> nq;

    left.push(-MAX);
    right.push(MAX);

    ll cons = 0;  // constant
    int n_item = 0;
    ll sum_left = 0, sum_right = 0;

    for (int i = 0; i < nq; i++){
        ll tmp;
        cin >> tmp;

        if (tmp == 1){
            ll a, b;
            cin >> a >> b;
            cons += b;


            if (n_item == 0){
                med = a;
            }else if (n_item % 2 == 0){
                // # items is even
                if (left.top() <= a && a <= right.top()){
                    med = a;
                }else if (a < left.top()){
                    med = left.top();
                    left.pop();
                    left.push(a);

                    sum_left -= med;
                    sum_left += a;
                }else{
                    med = right.top();
                    right.pop();
                    right.push(a);

                    sum_right -= med;
                    sum_right += a;
                }
            }else{
                // # items is odd
                if (a < med){
                    left.push(a);
                    right.push(med);

                    sum_left += a;
                    if (med != -MAX - 1) sum_right += med;

                    med = -MAX - 1;

                }else{
                    right.push(a);
                    left.push(med);

                    sum_right += a;
                    if (med != -MAX - 1) sum_left += med;

                    med = -MAX - 1;
                }
            }
            n_item++;
        } else if (tmp == 2){
            ll fx = -sum_left + sum_right + cons;
            if (n_item == 0){
                cout << "omg" << endl;
            }else if (n_item % 2 == 0){
                cout << left.top() << " " << fx << endl;
            }else{
                cout << med << " " << fx << endl;
            }
        }

        // debug
        // cout << "-->";
        // vector<ll> tmp_left, tmp_right;
        // while (not left.empty()){
        //     tmp_left.push_back(left.top());
        //     cout << left.top() << " ";
        //     left.pop();
        // }
        // cout << "|";
        // cout << med;
        // cout << "|";
        // while (not right.empty()){
        //     tmp_right.push_back(right.top());
        //     cout << right.top() << " ";
        //     right.pop();
        // }
        // cout << endl;

        // for (auto a : tmp_left) left.push(a);
        // for (auto a : tmp_right) right.push(a);
        // tmp_left.clear(); tmp_right.clear();
    }


    return 0;
}
















Measured memory_bytes: 3828