#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class BIT {
    public:
        BIT(int n) : N(n), data(n, 0) {

        }

        void put(int x, long long v) {
            for (; x < N; x |= x + 1) {
                data[x] += v;
            }
        }

        long long get(int x) {
            long long res = 0;
            for (; x >= 0; x = (x & (x + 1)) - 1) {
                res += data[x];
            }
            return res;
        }

        int kthElement(long long K) {
            int res = 0;
            int h = 0;
            while (1 << (h + 1) <= N) {
                ++h;
            }

            for (int i = h; i >= 0; --i) {
                if (res + (1 << i) <= N) {
                    if (data[res + (1 << i) - 1] < K) {
                        K -= data[res + (1 << i) - 1];
                        res |= 1 << i;
                    }
                }
            }
            return res;
        }

    private:
        int N;
        vector<long long> data;
};

class Solution {
public:
    vector<pair<long long, long long>> solve(vector<pair<int,pair<long long, long long>>>& queries) {
        vector<long long> X;
        for (auto& q : queries) {
            if (q.first == 1) {
                long long a = q.second.first;
                long long b = q.second.second;
                X.push_back(a);
            }
        }

        sort(X.begin(), X.end());
        X.erase(unique(X.begin(), X.end()), X.end());
        auto index = [&](long long x) {
            return lower_bound(X.begin(), X.end(), x) - X.begin();
        };

        BIT bitCnt(X.size() + 123);
        BIT bitSum(X.size() + 123);

        vector<pair<long long, long long>> res;
        long long N = 0;
        long long B = 0;
        long long A = 0;
        for (auto& q :queries) {
            if (q.first == 1) {
                long long a = q.second.first;
                long long b = q.second.second;
                int x = index(a);
                bitCnt.put(x, 1);
                bitSum.put(x, a);
                A += a;
                B += b;
                ++N;
            } else {
                int l = (N - 1) / 2 + 1;
                int r = N - l;
                long long m1 = bitCnt.kthElement(l);
                // long long m2 = m1;
                // if ((N & 1) == 0) {
                //     m2 = bitCnt.kthElement(N / 2 + 1);
                // }
                long long L = bitSum.get(m1 - 1);
                long long cnt = bitCnt.get(m1 - 1);
                assert(cnt < l);
                assert(A == bitSum.get(X.size()));

                L += (l - cnt) * X[m1];

                // long long ans = X[m1] * l - L;
                // ans += A - L - X[m1] * r;
                
                long long ans = A - L - L + ((N & 1) == 1 ? X[m1] : 0);
                ans += B;
                res.emplace_back(X[m1], ans);

                // cout << N << " " << m1 << " " << m2 << " " <<  l << " " << r << " " << L << endl;

            }
        }
        return res;
    }

private:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int q;
    cin >> q;
    
    vector<pair<int, pair<long long, long long>>> queries;

    Solution sol;
    while (q-- > 0) {
        int t;
        cin >> t;
        if (t == 1) {
            long long a, b;
            cin >> a >> b;
            queries.emplace_back(1, make_pair(a, b));
        } else {
            queries.emplace_back(2, make_pair(0, 0));
        }
    }
    auto res = sol.solve(queries);
    for (auto& r : res) {
        cout << r.first << ' ' << r.second << '\n';
    }
    return 0;
}

Measured memory_bytes: 14316