#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
void Unused(...) {}
#ifndef DEBUG
  #define echo(...) Unused(__VA_ARGS__)
#else
  #define echo(...) fprintf(stderr, __VA_ARGS__)
#endif

typedef long long laolin;

const int MaxN = int(2e5) + 7;

int q;
laolin totb;

class AnsTree
{
private:
    int width[MaxN];
    int weight[MaxN];
    int child[MaxN][2];
    laolin value[MaxN];
    laolin sum[MaxN];

    int root, id;
    int alloc(int val)
    {
        int res = ++id;
        width[res] = 1;
        weight[res] = rand();
        child[res][0] = child[res][1] = 0;
        sum[res] = value[res] = val;
        return res;
    }

    void update(int now)
    {
        if (now)
        {
            int lch = child[now][0], rch = child[now][1];
            width[now] = width[lch] + width[rch] + 1;
            sum[now] = value[now] + sum[lch] + sum[rch];
        }
    }

    template<int type>
    bool spprec(int now, int &arg);
    template<int type>
    void split(int now, int arg, int &left, int &right)
    {
        if (!now)
        {
            left = right = 0;
            return;
        }
        if (spprec<type>(now, arg))
        {
            left = now;
            split<type>(child[now][1], arg, child[now][1], right);
        }
        else
        {
            right = now;
            split<type>(child[now][0], arg, left, child[now][0]);
        }
        update(now);
    }

    int merge(int left, int right)
    {
        if (!left || !right)
            return left + right;
        int res;
        if (weight[left] > weight[right])
        {
            res = left;
            child[res][1] = merge(child[res][1], right);
        }
        else
        {
            res = right;
            child[res][0] = merge(left, child[res][0]);
        }
        update(res);
        return res;
    }

public:
    AnsTree() : root(0), id(0) {}

    void insert(int val);
    void query(int at);
};

#define newsp(type, expr) \
    const int type = __LINE__; \
    template<> bool AnsTree::spprec<type>(int now, int &arg) { return expr; }

newsp(ByVal, value[now] <= arg);
void AnsTree::insert(int val)
{
    int left, right;
    split<ByVal>(root, val, left, right);
    root = merge(merge(left, alloc(val)), right);
}

newsp(ByLen, (width[child[now][0]] < arg ? (arg -= width[child[now][0]] + 1, true) : false));
void AnsTree::query(int at)
{
    int left, mid, right;
    split<ByLen>(root, at - 1, left, right);
    split<ByLen>(right, 1, mid, right);
    printf("%lld ", value[mid]);
    //laolin res = value[mid] * width[left] - sum[left] + sum[right] - value[mid] * width[right];
    laolin res = value[mid] * (width[left] - width[right]) - sum[left] + sum[right];
    printf("%lld\n", res + totb);
    root = merge(merge(left, mid), right);
}

#undef newsp

AnsTree atr;

int main()
{
    srand(19260817);
    scanf("%d", &q);
    for (int i = 0, tot = 0; i < q; ++i)
    {
        int op, a, b;
        scanf("%d", &op);
        if (op == 2)
            atr.query((tot + 1) / 2);
        else
        {
            scanf("%d %d", &a, &b);
            atr.insert(a);
            totb += b;
            ++tot;
        }
    }
    return 0;
}



Measured memory_bytes: 8064