#include <cstdint>
#include <iostream>
#include <random>

using namespace std;

int RandInt()
{
    static mt19937 gen_rand;
    static uniform_int_distribution<int> dist(1, 1e7);

    return dist(gen_rand);
}

struct TreapNode
{
    TreapNode(int64_t key)
        : count(1), sum(key), key(key), priority(RandInt()) {}

    ~TreapNode()
    {
        if (left) {
            delete left;
        }
        if (right) {
            delete right;
        }
    }

    TreapNode *left = nullptr;
    TreapNode *right = nullptr;

    int64_t count = 0;
    int64_t sum = 0;
    int64_t key;
    int priority;
};

void RotateLeft(TreapNode *&node)
{
    auto right = node->right;

    node->count -= right->count;
    node->sum -= right->sum;

    if (right->left) {
        node->count += right->left->count;
        node->sum += right->left->sum;

        right->count -= right->left->count;
        right->sum -= right->left->sum;
    }

    right->count += node->count;
    right->sum += node->sum;

    node->right = right->left;
    right->left = node;
    node = right;
}

void RotateRight(TreapNode *&node)
{
    auto left = node->left;

    node->count -= left->count;
    node->sum -= left->sum;

    if (left->right) {
        node->count += left->right->count;
        node->sum += left->right->sum;

        left->count -= left->right->count;
        left->sum -= left->right->sum;
    }

    left->count += node->count;
    left->sum += node->sum;

    node->left = left->right;
    left->right = node;
    node = left;
}

void Rebalance(TreapNode *&node)
{
    auto left = node->left;
    auto right = node->right;

    auto max_priority = max(left ? left->priority : -1,
                            right ? right->priority : -1);

    if (max_priority <= node->priority) {
        return;
    }

    auto go_left = (!left || (right && right->priority == max_priority));
    go_left ? RotateLeft(node) : RotateRight(node);
}


void Insert(TreapNode *&root, int64_t key)
{
    if (!root) {
        root = new TreapNode(key);
        return;
    }

    root->count += 1;
    root->sum += key;

    if (key < root->key) {
        Insert(root->left, key);
    } else {
        Insert(root->right, key);
    }
    Rebalance(root);
}

int64_t KthKey(const TreapNode *root, int64_t count)
{
    if (!root) {
        return -1;
    }

    if (root->left) {
        if (count <= root->left->count) {
            return KthKey(root->left, count);
        }
        count -= root->left->count;
    }

    if (count == 1) {
        return root->key;
    }
    return KthKey(root->right, count - 1);
}

int64_t SumSmaller(const TreapNode *root, int64_t count)
{
    if (!root || count <= 0) {
        return 0;
    }

    int64_t sum = 0;
    if (root->left) {
        if (root->left->count >= count) {
            return SumSmaller(root->left, count);
        }
        count -= root->left->count;
        sum += root->left->sum;
    }

    sum += root->key;
    return sum + SumSmaller(root->right, count - 1);
}

class Treap
{
public:
    ~Treap()
    {
        if (root_) {
            delete root_;
        }
    }

    int Size() const { return size_; }

    int MiddlePos() const { return (size_ + 1) / 2; }

    int64_t MiddleKey() const { return ::KthKey(root_, MiddlePos()); }

    int64_t SumSmaller(int64_t pos) const { return ::SumSmaller(root_, pos); }

    int64_t Total() const { return (root_ ? root_->sum : 0); }

    void Insert(int64_t key)
    {
        size_ += 1;
        ::Insert(root_, key);
    }

private:
    TreapNode *root_ = nullptr;
    int size_ = 0;
};

int64_t FindMin(const Treap &treap)
{
    auto mid = treap.MiddlePos();
    auto key = treap.MiddleKey();

    auto n1 = mid;
    auto n2 = treap.Size() - n1;

    auto sum1 = treap.SumSmaller(mid);
    auto sum2 = treap.Total() - sum1;

    return n1 * key - sum1 + sum2 - n2 * key;
}

int main()
{
    int n;
    cin >> n;

    Treap treap;
    int64_t bs = 0;

    for (auto i = 0; i < n; i += 1) {
        int type;
        cin >> type;

        if (type == 1) {
            int64_t a, b;
            cin >> a >> b;

            treap.Insert(a);
            bs += b;
        } else {
            cout << treap.MiddleKey() << " ";
            cout << bs + FindMin(treap) << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 12800