Problem: Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that:

  * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. 
  * Among all such subsequences, choose the one whose length, k, is as small as possible. 



If multiple subsequences satisfy these conditions, you are allowed to find any of them.

A sequence a is a subsequence of an array b if a can be obtained from b by deleting some (possibly, zero or all) elements.

A permutation of length n is an array of length n in which every element from 1 to n occurs exactly once.

Input

The first line contains an integer t (1 ≤ t ≤ 2 ⋅ 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer n (2 ≤ n ≤ 10^5) — the length of the permutation p.

The second line of each test case contains n integers p_1, p_2, …, p_{n} (1 ≤ p_i ≤ n, p_i are distinct) — the elements of the permutation p.

The sum of n across the test cases doesn't exceed 10^5.

Output

For each test case, the first line should contain the length of the found subsequence, k. The second line should contain s_1, s_2, …, s_k — its elements.

If multiple subsequences satisfy these conditions, you are allowed to find any of them.

Example

Input


2
3
3 2 1
4
1 3 4 2


Output


2
3 1 
3
1 4 2 

Note

In the first test case, there are 4 subsequences of length at least 2:

  * [3,2] which gives us |3-2|=1. 
  * [3,1] which gives us |3-1|=2. 
  * [2,1] which gives us |2-1|=1. 
  * [3,2,1] which gives us |3-2|+|2-1|=2. 



So the answer is either [3,1] or [3,2,1]. Since we want the subsequence to be as short as possible, the answer is [3,1].

Solution (in JAVA):

Solution:


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException; 
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;

import static java.lang.System.out;
public class c693a
{ 
    //By shwetank_verma
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static int mod=1000000007;
    static boolean primes[]=new boolean[1000007];
    static ArrayList<Integer> b=new ArrayList<>();
    static void seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
        	for(int i=2;i<=n;i++) {
        		if(primes[i])
        			b.add(i);
        	}
           // return primes[n];
        }
     //   return false;
        
    }
    static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    }
    static ArrayList<Integer> segseive(int l,int r){
    	
    	ArrayList<Integer> isprime=new ArrayList<Integer>();
    	boolean p[]=new boolean[r-l+1];
    	Arrays.fill(p, true);
        
    	for(int i=0;b.get(i)*b.get(i)<=r;i++) {
    		int currprime=b.get(i);
    		int base=(l/currprime)*currprime;
    		if(base<l) {
    			base+=currprime;
    		}
    		for(int j=base;j<=r;j+=currprime) {
    			p[j-l]=false;
    		}
    		
    		
    		if(base==currprime) {
    			p[base-l]=true;
    		}
    		
    	}
    	for(int i=0;i<=r-l;i++) {
    		if(p[i])
    			isprime.add(i+l);
    	}
    	return isprime;
    }
      static int LowerBound(int a[], int x) { // x is the target value or key
  int l=-1,r=a.length;
  while(l+1<r) {
    int m=l+(r-l)/2;
    if(a[m]>=x) r=m;
    else l=m;
  }
  return r;
}
static int UpperBound(int a[], int x) {// x is the key or target value
    int l=-1,r=a.length;
    while(l+1<r) {
       int m=(l+r)>>>1;
       if(a[m]<=x) l=m;
       else r=m;
    }
    return l+1;
 }
static int ans=0;
  static void dfs(ArrayList<ArrayList<Integer>> adj,boolean visited[],int s,int c,int m,int val[]) {
	  visited[s]=true;
	  if(c<=m) {
		  if(val[s]==1)
			  c++;
		  else
			  c=0;
	  }
	  if(c>m)
		  return;
	  if(adj.get(s).size()==1&&s>1)
		  ans++;
	  for(int i:adj.get(s)) {
		  if(!visited[i]) {
			  
			  dfs(adj,visited,i,c,m,val);
			  
		  }
	  }
  }
  static void addEdge(ArrayList<ArrayList<Integer>> adj,int u,int v) {
	  adj.get(u).add(v);
	  adj.get(v).add(u);
  }
  static void bfs(ArrayList<ArrayList<Integer>> adj,int dist[],boolean visited[],int s) {
	  Queue<Integer> q=new ArrayDeque();
	  q.add(s);
	  visited[s]=true;
	  dist[s]=0;
	  while(!q.isEmpty()) {
		  s=q.poll();
		  for(int i:adj.get(s)) {
			  if(!visited[i]) {
				  visited[i]=true;
				  dist[i]=dist[s]+1;
				  q.add(i);
			  }
		  }
	  }
  }
 
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        
                int t=1;
                t=sc.nextInt();
                
                while(t-->0){
               int n=sc.nextInt();
              
               int a[]=new int[n];
               for(int i=0;i<n;i++) {
            	   a[i]=sc.nextInt();
            	   
               }
               if(n!=2) {
               ArrayList<Integer> l=new ArrayList<Integer>();
               l.add(a[0]);
               for(int i=1;i<n-1;i++) {
            	   if(a[i]>a[i-1]&&a[i]>a[i+1]) {
            		   l.add(a[i]);
            		   
            	   }
            	   if(a[i]<a[i+1]&&a[i]<a[i-1]) {
            		   l.add(a[i]);
            	   }
            	   
            	   
               }
               l.add(a[n-1]);
               out.println(l.size());
               for(int i:l) {
            	   out.print(i+" ");
               }
               }
               else {
            	   out.println(n);
            	   for(int i:a)
            		   out.print(i+" ");
               }
               out.println();
               
                }
           
        
        out.flush();
    } 
}