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

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

int main() {
    int q = read();
    priority_queue<int> l;
    priority_queue<int, vector<int>, greater<int> > r;
    long long ans = 0;
    while (q--) {
        int t = read();
        if (t == 1) {
            int a = read(), b = read();
            ans += b;
            l.push(a);
            r.push(a);
            if (l.top() > r.top()) {
                int x = l.top(); l.pop();
                int y = r.top(); r.pop();
                ans += abs(x - y);
                l.push(y); r.push(x);
            }
        } else {
            printf("%d %lld\n", l.top(), ans);
        }
    }
    return 0;
}