use std::io::*;


mod rand {
    static mut SEED: u64 = 88172645463325252;

    pub fn next() -> u64 {
        unsafe {
            SEED ^= SEED<<13; SEED ^= SEED>>7; SEED ^= SEED<<17;
            SEED
        }
    }
}


mod treap {
    use rand;


    #[derive(Debug)]
    pub struct Node {
        v: i64,
        pri: u64,
        lch: Option<Box<Node>>,
        rch: Option<Box<Node>>,
        cnt: usize,
        sum: i64,
    }


    pub type Tree = Option<Box<Node>>;


    fn tree(n:Node) -> Tree {
        Some(Box::new(n))
    }


    pub fn leaf(v:i64) -> Node {
        Node {
            v:v,
            pri: rand::next(),
            lch: None,
            rch: None,
            cnt: 1,
            sum: v,
        }
    }


    pub fn count(t: &Tree) -> usize {
        match *t {
            None => 0,
            Some(ref n) => n.cnt,
        }
    }


    pub fn sum(t: &Tree) -> i64 {
        match *t {
            None => 0,
            Some(ref n) => n.sum,
        }
    }


    pub fn update(t: Tree) -> Tree {
        match t {
            None => t,
            Some(mut n) => {
                n.cnt = count(&n.lch) + count(&n.rch) + 1;
                n.sum = sum(&n.lch) + sum(&n.rch) + n.v;
                Some(n)
            }
        }
    }


    pub fn merge(tl: Tree, tr: Tree) -> Tree {
        match (tl, tr) {
            (None, None) => None,
            (l, None) => l,
            (None, r) => r,
            (Some(mut l), Some(mut r)) => {
                if l.pri > r.pri {
                    l.rch = merge(l.rch.take(), Some(r));
                    update(Some(l))
                }
                else {
                    r.lch = merge(Some(l), r.lch.take());
                    update(Some(r))
                }
            }
        }
    }


    pub fn split(t: Tree, k: usize) -> (Tree, Tree) {
        match t {
            None => (None, None),
            Some(mut n) => {
                let cnt = count(&n.lch);
                if k <= cnt {
                    let (l,r) = split(n.lch.take(), k);
                    n.lch = r;
                    (l, update(Some(n)))
                }
                else {
                    let (l,r) = split(n.rch.take(), k - cnt - 1);
                    n.rch = l;
                    (update(Some(n)), r)
                }
            }
        }
    }


    pub fn insert(t: Tree, k: usize, v: i64) -> Tree {
        let (l, r) = split(t, k);
        merge(l, merge(tree(leaf(v)), r))
    }


    pub fn get(t: &Tree, k: usize) -> Option<i64> {
        match *t {
            None => None,
            Some(ref n) => {
                let cnt = count(&n.lch);
                if k == cnt {
                    Some(n.v)
                }
                else if  k < cnt {
                    get(&n.lch, k)
                }
                else {
                    get(&n.rch, k - cnt - 1)
                }
            }
        }
    }


    pub fn bisect(t: &Tree, v: i64) -> usize {
        match *t {
            None => 0,
            Some(ref n) => {
                if v <= n.v {
                    bisect(&n.lch, v)
                }
                else {
                    count(&n.lch) + 1 + bisect(&n.rch, v)
                }
            }
        }
    }
}


struct Treap {
    t: treap::Tree
}


impl Treap {
    fn new() -> Treap {
        Treap { t: None }
    }


    fn insert(&mut self, k:usize, v:i64) {
        self.t = treap::insert(self.t.take(), k, v);
    }


    fn ordered_insert(&mut self, v:i64) {
        let idx = treap::bisect(&self.t, v);
        self.insert(idx, v);
    }


    fn get(&self, k:usize) -> i64 {
        treap::get(&self.t, k).unwrap_or_else(|| panic!("idx: {}", k))
    }


    fn sum(&mut self, l:usize, r:usize) -> i64 {
        let t = self.t.take();
        let (lt, t) = treap::split(t, l);
        let (t, rt) = treap::split(t, r-l);
        let res = treap::sum(&t);
        self.t = treap::merge(lt, treap::merge(t, rt));
        res
    }


    fn len(&self) -> usize {
        treap::count(&self.t)
    }
}


use std::fmt::Write;
fn solve(buf: String) -> String {
    let mut it: Vec<i64> = buf.trim().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    it.reverse();

    let q = it.pop().unwrap() as usize;

    let mut ans = String::new();
    let mut sum_b = 0;
    let mut A = Treap::new();
    for _ in 0..q {
        let kind = it.pop().unwrap();
        match kind {
            1 => {
                let a = it.pop().unwrap();
                let b = it.pop().unwrap();
                A.ordered_insert(a);
                sum_b += b;
            },
            2 => {
                let n = A.len();
                let mid = (n-1)/2;
                let x = A.get(mid);
                let mut sum_abs = 0;
                let sum_total = treap::sum(&A.t);
                let sum_left = A.sum(0,mid);
                let sum_right = sum_total - sum_left - x;
                sum_abs += x*(mid as i64) - sum_left;
                sum_abs += sum_right - x*(n as i64 - 1 - mid as i64);
                write!(ans, "{} {}\n", x, sum_abs+sum_b).unwrap();
            },
            _ => {
                unreachable!()
            }
        }
    }
    ans
}


fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    print!("{}", solve(buf));
}

Measured memory_bytes: 24820