There is a function f(x), which is initially a constant function f(x) = 0.

We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:

* An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x).
* An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value.



We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.

Constraints

* All values in input are integers.
* 1 \leq Q \leq 2 \times 10^5
* -10^9 \leq a, b \leq 10^9
* The first query is an update query.

Input

Input is given from Standard Input in the following format:


Q
Query_1
:
Query_Q


See Sample Input 1 for an example.

Output

For each evaluation query, print a line containing the response, in the order in which the queries are given.

The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between.

Examples

Input

4
1 4 2
2
1 1 -8
2


Output

4 2
1 -3


Input

4
1 -1000000000 1000000000
1 -1000000000 1000000000
1 -1000000000 1000000000
2


Output

-1000000000 3000000000
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int q[][] = new int[3][n];
        HashMap<Integer, Integer> mp = new HashMap<>();
        HashMap<Integer, Integer> mpid = new HashMap<>();
        ArrayList<Integer> l=new ArrayList<>();
        for (int i = 0; i < n; i++) {
			q[0][i]=sc.nextInt();
			if(q[0][i]==1) {
				q[1][i]=sc.nextInt();
				q[2][i]=sc.nextInt();
				l.add(q[1][i]);
			}
		}
        sort(l);
        for (int i = 0, c=0; i < l.size(); i++) {
        	int x=l.get(i);
			if(!mp.containsKey(x)) {
				mp.put(x, ++c);
				mpid.put(c, x);
			}
		}

        bit app=new bit(n);
        bit sum=new bit(n);
        long bs=0;

        for (int i = 0,c=0,md; i < n; i++) {
			if(q[0][i]==2) {
				md=app.lb(c%2==0?c/2:c/2+1);
			    long val=mpid.get(md),msl=app.sum(md-1)
			    		  ,msr=app.sum(n)-app.sum(md);
//			    db("s",md,bs,msl,msr,val);
			    out.println(val+" "+(
			    		msl*val-sum.sum(md-1)-msr*val+sum.sum(n)
			    		-sum.sum(md)+bs));

			} else {
				c++;
				md=mp.get(q[1][i]);
				bs+=q[2][i];
				app.add(md, 1);
				sum.add(md, q[1][i]);
			}
		}
        
        out.println();
     	out.flush();
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}
class bit {
    int n;
    long b[]; 
    bit(int n){
        this.n = n;
        b = new long[n+1];
    }
    long sum(int i){
        long s = 0;
        while(i > 0){
            s += b[i];
            i -= i&-i;
        }
        return s;   
    }
    void add(int i, int x){
        while(i <= n){
            b[i] += x;
            i += i&-i;
        }
    }
    
    int lb(long x) {
    	//lower bound sum(i)がx以上となるような最小のi
    	int dw=1,up=n,md,min=this.n+1;
    	for (int i = 0; i < 60; i++) {
			md=(dw+up)/2;
			if(x<=sum(md)) {
				min=min(min,md);
				up=md;
			} else {
				dw=md;
			}
		}
    	if(min==n+1)return -1;
    	return min;
    }
}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return p.a-a;//des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}
