#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
use std::cmp::Ordering;

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
struct Rev(i64);

impl Ord for Rev {
    fn cmp(&self, other: &Rev) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl PartialOrd for Rev {
    fn partial_cmp(&self, other: &Rev) -> Option<Ordering> {
        Some(other.0.cmp(&self.0))
    }
}


pub struct Scanner<R> {
    reader: R,
}
impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf: String = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        buf.parse::<T>().ok().expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner { reader: stdin.lock() };

    let q: usize = sc.read();

    let mut bb = 0 as i64;

    use std::collections::BinaryHeap;
    let mut lq = BinaryHeap::new();
    let mut rq = BinaryHeap::new();

    let mut min_ans = 0;
    for _ in 0..q {
        let t:usize = sc.read();
        if t == 1 {
            let a:i64 = sc.read();
            let b:i64 = sc.read();

            let l = lq.pop();
            let r = rq.pop();

            match (l, r) {
                (None, None) => {
                    lq.push(a);
                },
                (Some(l), None) => {
                    if l < a {
                        lq.push(l);
                        rq.push(Rev(a));
                    } else {
                        lq.push(a);
                        rq.push(Rev(l));
                    }
                    min_ans = (l-a).abs();
                },
                (Some(l), Some(Rev(r))) => {
                    if lq.len() == rq.len() {
                        if l <= a && a <= r {
                            lq.push(l);
                            lq.push(a);
                            rq.push(Rev(r));
                        } else if a < l {
                            lq.push(a);
                            lq.push(l);
                            rq.push(Rev(r));
                            min_ans += (l-a).abs();
                        } else {
                            lq.push(l);
                            lq.push(r);
                            rq.push(Rev(a));
                            min_ans += (r-a).abs();
                        }
                    } else {
                        if l <= a && a <= r {
                            lq.push(l);
                            rq.push(Rev(a));
                            rq.push(Rev(r));
                            min_ans += (l-a).abs();
                        } else if a < l {
                            lq.push(a);
                            rq.push(Rev(l));
                            rq.push(Rev(r));
                            min_ans += (l-a).abs();
                        } else {
                            lq.push(l);
                            rq.push(Rev(a));
                            rq.push(Rev(r));
                            min_ans += (l-a).abs();
                        }
                    }
                },
                _ => unreachable!(),
            };

            bb += b;
        } else {
            let x = lq.peek().unwrap();
            println!("{} {}", x, min_ans+bb);
        }
    }
}


Measured memory_bytes: 6908