import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C_POST {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while (t-- > 0) {
			int n = Integer.parseInt(br.readLine());
			String str = br.readLine();
			StringBuilder a = new StringBuilder();
			StringBuilder b = new StringBuilder();
			boolean ptr = false;
			for (int i = 0; i < n; i++) {
				if (str.charAt(i) == '0') {
					a.append('0');
					b.append('0');
				} else if (str.charAt(i) == '1') {
					if (!ptr) {
						a.append('0');
						b.append('1');
						ptr = false;
					} else {
						a.append('1');
						b.append('0');
					}
				} else if (str.charAt(i) == '2') {
					a.append('1');
					b.append('1');
				}
			}
			System.out.println(a.toString());
			System.out.println(b.toString());
		}
	}
}


mport java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C_POST {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while (t-- > 0) {
			int n = Integer.parseInt(br.readLine());
			String str = br.readLine();
			StringBuilder a = new StringBuilder();
			StringBuilder b = new StringBuilder();
			boolean ptr = false;
			for (int i = 0; i < n; i++) {
				if (str.charAt(i) == '0') {
					a.append('0');
					b.append('0');
				} else if (str.charAt(i) == '1') {
					if (!ptr) {
						a.append('0');
						b.append('1');
						ptr = false;
					} else {
						a.append('1');
						b.append('0');
					}
				} else if (str.charAt(i) == '2') {
					a.append('1');
					b.append('1');
				}
			}
			System.out.println(a.toString());
			System.out.println(b.toString());
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String Args[])throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder st =  new StringBuilder();
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			String s = br.readLine();
			String s1 = "";
			String s2 = "";
			for(int i = 0;i<n;i++)
			{
				if(s.charAt(i)=='2')
				{
					s1 = s1+"1";
					s2= s2+"1";
				}
				else if(s.charAt(i)=='1')
				{
					s1 = s1 +"1";
					s2 = s2+"0";
					s2 = s2+s.substring(i+1);
					for(int j = 1;j<=n-i-1;j++)
						s1 = s1+"0";
					break;
				}
				else
				{
					s1 = s1+"0";
					s2 = s2+"0";
				}
			}
			st.append(s1+"\n"+s2+"\n");
		}
		System.out.println(st.toString());
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String Args[])throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());

		while(t-->0)
		{
			StringBuilder s1 =  new StringBuilder();
			StringBuilder s2 = new StringBuilder();
			int n = Integer.parseInt(br.readLine());
			String s = br.readLine();

			for(int i = 0;i<n;i++)
			{
				if(s.charAt(i)=='2')
				{
					s1.append("1");
					s2.append("1");
				}
				else if(s.charAt(i)=='1')
				{
					s1.append("1");
					s2.append( "0");
					s2.append(s.substring(i+1));
					for(int j = 1;j<=n-i-1;j++)
						s1.append("0");
					break;
				}
				else
				{
					s1.append("0");
					s2.append("0");
				}
			}
			System.out.println(s1.toString()+"\n"+s2.toString());
		}

	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String Args[])throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder st =  new StringBuilder();
		String zeros= "0";
		zeros = fill(zeros);
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			String s = br.readLine();
			String s1 = "";
			String s2 = "";
			for(int i = 0;i<n;i++)
			{
				if(s.charAt(i)=='2')
				{
					s1 = s1+"1";
					s2= s2+"1";
				}
				else if(s.charAt(i)=='1')
				{
					s1 = s1 +"1";
					s2 = s2+"0";
					s2 = s2+s.substring(i+1);
					s1 = s1+zeros.substring(0,n-i-1);
					break;
				}
				else
				{
					s1 = s1+"0";
					s2 = s2+"0";
				}
			}
			st.append(s1+"\n"+s2+"\n");
		}
		System.out.println(st.toString());
	}

	private static String fill(String zeros) {
		// TODO Auto-generated method stub
		while(zeros.length()<=50000)
		{
		zeros = zeros+zeros;
		}
		return zeros;
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String Args[])throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder st =  new StringBuilder();
		String zeros= "0";
		zeros = fill(zeros);
		String ones = "1";
		ones = fill(ones);
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			String s = br.readLine();
			String s1 = "";
			String s2 = "";
			int pos = s.indexOf('1');
			int pos0 = s.indexOf('0');
			if(pos==-1&&pos0==-1)
			{
				s1 = ones.substring(0,n);
				s2 = ones.substring(0,n);
			}
			else if(pos==-1||pos0==-1)
			{
				if(pos0==-1)
				{
					s1 = ones.substring(0,pos+1)+zeros.substring(0,n-pos-1);
					s2 = ones.substring(0,pos)+"0"+s.substring(pos+1);
				}
				else
				{
					while(pos0!=-1)
					{
						s1 = s1+ones.substring(0,pos0)+"0";
						s2 = s2+ones.substring(0,pos0)+"0";
						s = s.substring(pos0+1);
						pos0 = s.indexOf("0");
					}
					s1+=ones.substring(0,s.length());
					s2+=ones.substring(0,s.length());
				}
			}
			else if(pos<pos0)
			{
				s1 = ones.substring(0,pos+1)+zeros.substring(0,n-pos-1);
				s2 = ones.substring(0,pos+1)+s.substring(pos+1);
			}
			else if(pos0<pos)
			{
				while(pos0<pos&&pos0!=-1)
				{
					s1 = s1+ones.substring(0,pos0)+"0";
					s2 = s2+ones.substring(0,pos0)+"0";
					s = s.substring(pos0+1);
					pos0 = s.indexOf("0");
					pos = s.indexOf("1");
				}
				s1 += ones.substring(0,pos+1)+zeros.substring(0,s.length()-pos-1);
				s2 += ones.substring(0,pos)+"0"+s.substring(pos+1);
			}

			st.append(s1+"\n"+s2+"\n");
		}
		System.out.println(st.toString());
	}

	private static String fill(String zeros) {
		// TODO Auto-generated method stub
		while(zeros.length()<=50000)
		{
		zeros = zeros+zeros;
		}
		return zeros;
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String Args[])throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder s1 =  new StringBuilder();
		StringBuilder s2 = new StringBuilder();
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			String s = br.readLine();

			for(int i = 0;i<n;i++)
			{
				if(s.charAt(i)=='2')
				{
					s1.append("1");
					s2.append("1");
				}
				else if(s.charAt(i)=='1')
				{
					s1.append("1");
					s2.append( "0");
					s2.append(s.substring(i+1));
					for(int j = 1;j<=n-i-1;j++)
						s1.append("0");
					break;
				}
				else
				{
					s1.append("0");
					s2.append("0");
				}
			}
			System.out.println(s1.toString()+"\n"+s2.toString());
		}

	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String Args[])throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder st =  new StringBuilder();
		String zeros= "0";
		zeros = fill(zeros);
		String ones = "1";
		ones = fill(ones);
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			String s = br.readLine();
			String s1 = "";
			String s2 = "";
			int pos = s.indexOf('1');
			int pos0 = s.indexOf('0');
			if(pos==-1&&pos0==-1)
			{
				s1 = ones.substring(0,n);
				s2 = ones.substring(0,n);
			}
			else if(pos==-1||pos0==-1)
			{
				if(pos0==-1)//0 is not present
				{
					s1 = ones.substring(0,pos+1)+zeros.substring(0,n-pos-1);
					s2 = ones.substring(0,pos)+"0"+s.substring(pos+1);
				}
				else
				{
					while(pos0!=-1)
					{
						s1 = s1+ones.substring(0,pos0)+"0";
						s2 = s2+ones.substring(0,pos0)+"0";
						s = s.substring(pos0+1);
						pos0 = s.indexOf("0");
					}
					s1+=ones.substring(0,s.length());
					s2+=ones.substring(0,s.length());
				}
			}
			else if(pos<pos0)
			{
				s1 = ones.substring(0,pos+1)+zeros.substring(0,n-pos-1);
				s2 = ones.substring(0,pos)+"0"+s.substring(pos+1);
			}
			else if(pos0<pos)
			{
				while(pos0<pos&&pos0!=-1)
				{
					s1 = s1+ones.substring(0,pos0)+"0";
					s2 = s2+ones.substring(0,pos0)+"0";
					s = s.substring(pos0+1);
					pos0 = s.indexOf("0");
					pos = s.indexOf("1");
				}
				s1 += ones.substring(0,pos+1)+zeros.substring(0,s.length()-pos-1);
				s2 += ones.substring(0,pos)+"0"+s.substring(pos+1);
			}

			st.append(s1+"\n"+s2+"\n");
		}
		System.out.println(st.toString());
	}

	private static String fill(String zeros) {
		// TODO Auto-generated method stub
		while(zeros.length()<=50000)
		{
		zeros = zeros+zeros;
		}
		return zeros;
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String Args[])throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		StringBuilder st =  new StringBuilder();
		String zeros= "0";
		zeros = fill(zeros);
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			String s = br.readLine();
			String s1 = "";
			String s2 = "";
			for(int i = 0;i<n;i++)
			{
				if(s.charAt(i)=='2')
				{
					s1 = s1+"1";
					s2= s2+"1";
				}
				else if(s.charAt(i)=='1')
				{
					s1 = s1 +"1";
					s2 = s2+"0";
					s2 = s2+s.substring(i+1);
					s1 = s1+zeros.substring(0,n-i-1);
					break;
				}
				else
				{
					s1 = s1+"0";
					s2 = s2+"0";
				}
			}
			st.append(s1+"\n"+s2+"\n");
		}
		System.out.println(st.toString());
	}

	private static String fill(String zeros) {
		// TODO Auto-generated method stub
		while(zeros.length()<=10000)
		{
		zeros = zeros+zeros;
		}
		return zeros;
	}
}


import java.util.Scanner;

public class TernaryXOR {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int t = input.nextInt();

		for (int i = 0; i < t; i++) {
			int n = input.nextInt();
			String str = input.next();

			boolean bool = false;

			StringBuffer ans1 = new StringBuffer();
			StringBuffer ans2 = new StringBuffer();

			for (int j = 0; j < n; j++) {
				if (str.charAt(j) == '0') {
					ans1.append(0);
					ans2.append(0);
				} else if (str.charAt(j) == '1' && bool == false) {
					ans1.append(1);
					ans2.append(0);

					bool = true;
				} else if (str.charAt(j) == '1' && bool == true) {
					ans1.append(0);
					ans2.append(1);
				} else {
					if (bool == true) {
						ans1.append(0);
						ans2.append(2);
					} else {
						ans1.append(1);
						ans2.append(1);
					}
				}
			}

			System.out.println(ans1);
			System.out.println(ans2);
		}
		input.close();
	}
}


import java.util.Scanner;

public class TernaryXOR {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int t = input.nextInt();

		for (int i = 0; i < t; i++) {
			int n = input.nextInt();
			String str = input.next();

			boolean bool = false;

			StringBuffer ans1 = new StringBuffer();
			StringBuffer ans2 = new StringBuffer();

			for (int j = 0; j < n; j++) {
				if (str.charAt(j) == '0') {
					ans1.append(0);
					ans2.append(0);
				} else if (str.charAt(j) == '1' && bool == false) {
					ans1.append(1);
					ans2.append(0);

					bool = true;
				} else if (str.charAt(j) == '1' && bool == true) {
					ans1.append(0);
					ans2.append(1);
				} else {
					if (bool == true) {
						ans1.append(0);
						ans2.append(2);
					} else {
						ans1.append(1);
						ans2.append(1);
					}
				}
			}

			System.out.println(ans1);
			System.out.println(ans2);
			input.close();
		}
	}
}


/*
 * Remember a 6.72 student can know more than a 10.0 student.
 * Grades don't determine intelligence, they test obedience.
 * I Never Give Up.
 * I will become Candidate Master.
 * I will defeat Saurabh Anand.
 * Skills are Cheap,Passion is Priceless.
 * Obsession is necessary.
 * Author : Sameer Raj
 */
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.Math.*;

import static java.lang.System.out;
import static java.util.Arrays.fill;
import static java.lang.Math.log;
import static java.lang.Math.abs;

public class ContestMain implements Runnable{
	private static Reader in=new Reader();
	private static StringBuilder ans=new StringBuilder();
	private static long MOD=(long)1e9+7;
	private static final int N=(int) (1e5+7); // 1e5+7
    private static ArrayList<Integer> v[]=new ArrayList[N];
	private static boolean mark[]=new boolean[N];
//    private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	/*Not try to hack the sort function*/
	public static void sort(long arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			long temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
	public static void sort(int arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			int temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
    private static long gcd(long a, long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }
    /*Code lies here*/
    @Override
	public void run(){
    	int t=in.nextInt();
    	int n,a[],b[],opt,set;
    	while(t-->0){
    		n=in.nextInt();
    		String x=in.next();
    		a=new int[n];
    		b=new int[n];
    		opt=0;
    		set=0;
    		fill(a,-1);fill(b,-1);
    		int ind=0;
    		for(int i=0;i<x.length();i++){
    			if(x.charAt(i)=='1'){
    				if(opt==0){a[i]=0;b[i]=1;}
    				else {b[i]=1;a[i]=0;}
    				ind=i;
    				break;
    			}
    			else if(x.charAt(i)=='2'){
    				a[i]=1;b[i]=1;
    			}
    			else {
    				a[i]=0;b[i]=0;
    			}
    			if(i==n-1)ind=n;
    		}
    		opt=0;
    		for(int i=ind+1;i<n;i++){
    			if(x.charAt(i)=='2'){
    				b[i]=0;a[i]=2;
    			}
    			else if(x.charAt(i)=='1'){
    				a[i]=1;b[i]=0;
    			}
    		}
    		for(int i=0;i<n;i++)
    			if(a[i]==-1){a[i]=1;b[i]=1;}
    		for(int i=0;i<n;i++)
    			app(a[i]);
    		app("\n");
    		for(int i=0;i<n;i++)
    			app(b[i]);
    		app("\n");
    	}
    	pn(ans);
	}
	public static void main(String[] args) throws IOException{
		new Thread(null,new ContestMain(),"Accepted",1<<26).start();
		/* 0_0 I am watching you 0_0 */
	}
	static class Pair<T> implements Comparable<Pair>{
		int l;
		int r;
		Pair(){
			l=0;
			r=0;
		}
		Pair(int k,int v){
			l=k;
			r=v;
		}
		@Override
		public int compareTo(Pair o){
			if(l!=o.l)return (int)(l-o.l);
			return (int)(r-o.r);
		}
		// Fenwick tree question comparator
//        @Override
//        public int compareTo(Pair o) {
//            if(o.r!=r)return (int) (r-o.r);
//            else return (int)(l-o.l);
//        }
	}
	/* BINARY SEARCH FUNCTIONS */
	public static int ceilSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int ceilSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int floorSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	public static int floorSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	/* MODULAR OPERATIONS */
	private static long mod(long a,long b){
	    	return (b+a%b)%b;
	}
	private static long modInv(long a){
	    	return powmod(a,MOD-2);
	}
	private static long powmod(long x,long n){
		if(n==0||x==0)return 1;
		else if(n%2==0)return(powmod((x*x)%MOD,n/2));
		else return (x*(powmod((x*x)%MOD,(n-1)/2)))%MOD;
	}
	public static long mult(long a,long b){
		return mod(mod(a,MOD)*mod(b,MOD),MOD);
	}
	public static long add(long a,long b){
		return mod(mod(a,MOD)+mod(b,MOD),MOD);
	}
	public static long sub(long a,long b){
		return mod(mod(a,MOD)-mod(b,MOD),MOD);
	}
	/* MAX-MIN FUNCTIONS */
	public static long min(long a,long b){
		return Math.min(a, b);
	}
	public static int min(int a,int b){
		return Math.min(a, b);
	}
	public static long max(long a,long b){
		return Math.max(a, b);
	}
	public static int max(int a,int b){
		return Math.max(a, b);
	}
	public static long min(long ar[]){
		return Arrays.stream(ar).min().getAsLong();
	}
	public static int min(int ar[]){
		return Arrays.stream(ar).min().getAsInt();
	}
	public static long max(long ar[]){
		return Arrays.stream(ar).max().getAsLong();
	}
	public static int max(int ar[]){
		return Arrays.stream(ar).max().getAsInt();
	}
	//Reader Class
	static class Reader{
		BufferedReader br;
		StringTokenizer st;
		public Reader(){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;
		}
	}
	//Looping methods
	static void rep(int ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextInt();
	}
	static void rep(long ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextLong();
	}
	static void rep(String ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.next();
	}
	//Printer Methods
	static void pn(Object o){out.print(o);}
	static void pln(Object o){out.println(o);}
	static void pln(){out.println();}
	static void pf(String format,Object o){out.printf(format,o);}
	//Appenders
	static void app(Object o){ans.append(o);}
	static void appn(Object o){ans.append(o+"\n");}
}


/*
 * Remember a 6.72 student can know more than a 10.0 student.
 * Grades don't determine intelligence, they test obedience.
 * I Never Give Up.
 * I will become Candidate Master.
 * I will defeat Saurabh Anand.
 * Skills are Cheap,Passion is Priceless.
 * Obsession is necessary.
 * Author : Sameer Raj
 */
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.Math.*;

import static java.lang.System.out;
import static java.util.Arrays.fill;
import static java.lang.Math.log;
import static java.lang.Math.abs;

public class ContestMain implements Runnable{
	private static Reader in=new Reader();
	private static StringBuilder ans=new StringBuilder();
	private static long MOD=(long)1e9+7;
	private static final int N=(int) (1e5+7); // 1e5+7
    private static ArrayList<Integer> v[]=new ArrayList[N];
	private static boolean mark[]=new boolean[N];
//    private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	/*Not try to hack the sort function*/
	public static void sort(long arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			long temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
	public static void sort(int arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			int temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
    private static long gcd(long a, long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }
    /*Code lies here*/
    @Override
	public void run(){
    	int t=in.nextInt();
    	int n,a[],b[],opt,set;
    	while(t-->0){
    		n=in.nextInt();
    		String x=in.next();
    		a=new int[n];
    		b=new int[n];
    		opt=0;
    		set=0;
    		fill(a,-1);fill(b,-1);
    		for(int i=0;i<x.length();i++){
    			if(x.charAt(i)=='1'){
    				if(opt==0){a[i]=0;b[i]=1;}
    				else {b[i]=1;a[i]=0;}
    				opt=opt^1;
    			}
    			else if(x.charAt(i)=='2'){
    				a[i]=1;b[i]=1;
    			}
    			else {
    				a[i]=0;b[i]=0;
    			}
    		}
    		opt=0;
    		for(int i=0;i<n;i++){
    			if(x.charAt(i)=='2'){
    				if(i-1>=0&&((a[i-1]==0&&b[i-1]==1)||(a[i-1]==1&&b[i-1]==0))){
    					b[i]=0;a[i]=2;
    				}
    			}
    		}
    		for(int i=0;i<n;i++)
    			if(a[i]==-1){a[i]=1;b[i]=1;}
    		for(int i=0;i<n;i++)
    			app(a[i]);
    		app("\n");
    		for(int i=0;i<n;i++)
    			app(b[i]);
    		app("\n");
    	}
    	pn(ans);
	}
	public static void main(String[] args) throws IOException{
		new Thread(null,new ContestMain(),"Accepted",1<<26).start();
		/* 0_0 I am watching you 0_0 */
	}
	static class Pair<T> implements Comparable<Pair>{
		int l;
		int r;
		Pair(){
			l=0;
			r=0;
		}
		Pair(int k,int v){
			l=k;
			r=v;
		}
		@Override
		public int compareTo(Pair o){
			if(l!=o.l)return (int)(l-o.l);
			return (int)(r-o.r);
		}
		// Fenwick tree question comparator
//        @Override
//        public int compareTo(Pair o) {
//            if(o.r!=r)return (int) (r-o.r);
//            else return (int)(l-o.l);
//        }
	}
	/* BINARY SEARCH FUNCTIONS */
	public static int ceilSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int ceilSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int floorSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	public static int floorSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	/* MODULAR OPERATIONS */
	private static long mod(long a,long b){
	    	return (b+a%b)%b;
	}
	private static long modInv(long a){
	    	return powmod(a,MOD-2);
	}
	private static long powmod(long x,long n){
		if(n==0||x==0)return 1;
		else if(n%2==0)return(powmod((x*x)%MOD,n/2));
		else return (x*(powmod((x*x)%MOD,(n-1)/2)))%MOD;
	}
	public static long mult(long a,long b){
		return mod(mod(a,MOD)*mod(b,MOD),MOD);
	}
	public static long add(long a,long b){
		return mod(mod(a,MOD)+mod(b,MOD),MOD);
	}
	public static long sub(long a,long b){
		return mod(mod(a,MOD)-mod(b,MOD),MOD);
	}
	/* MAX-MIN FUNCTIONS */
	public static long min(long a,long b){
		return Math.min(a, b);
	}
	public static int min(int a,int b){
		return Math.min(a, b);
	}
	public static long max(long a,long b){
		return Math.max(a, b);
	}
	public static int max(int a,int b){
		return Math.max(a, b);
	}
	public static long min(long ar[]){
		return Arrays.stream(ar).min().getAsLong();
	}
	public static int min(int ar[]){
		return Arrays.stream(ar).min().getAsInt();
	}
	public static long max(long ar[]){
		return Arrays.stream(ar).max().getAsLong();
	}
	public static int max(int ar[]){
		return Arrays.stream(ar).max().getAsInt();
	}
	//Reader Class
	static class Reader{
		BufferedReader br;
		StringTokenizer st;
		public Reader(){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;
		}
	}
	//Looping methods
	static void rep(int ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextInt();
	}
	static void rep(long ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextLong();
	}
	static void rep(String ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.next();
	}
	//Printer Methods
	static void pn(Object o){out.print(o);}
	static void pln(Object o){out.println(o);}
	static void pln(){out.println();}
	static void pf(String format,Object o){out.printf(format,o);}
	//Appenders
	static void app(Object o){ans.append(o);}
	static void appn(Object o){ans.append(o+"\n");}
}


/*
 * Remember a 6.72 student can know more than a 10.0 student.
 * Grades don't determine intelligence, they test obedience.
 * I Never Give Up.
 * I will become Candidate Master.
 * I will defeat Saurabh Anand.
 * Skills are Cheap,Passion is Priceless.
 * Obsession is necessary.
 * Author : Sameer Raj
 */
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.Math.*;

import static java.lang.System.out;
import static java.util.Arrays.fill;
import static java.lang.Math.log;
import static java.lang.Math.abs;

public class ContestMain implements Runnable{
	private static Reader in=new Reader();
	private static StringBuilder ans=new StringBuilder();
	private static long MOD=(long)1e9+7;
	private static final int N=(int) (1e5+7); // 1e5+7
    private static ArrayList<Integer> v[]=new ArrayList[N];
	private static boolean mark[]=new boolean[N];
//    private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	/*Not try to hack the sort function*/
	public static void sort(long arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			long temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
	public static void sort(int arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			int temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
    private static long gcd(long a, long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }
    /*Code lies here*/
    @Override
	public void run(){
    	int t=in.nextInt();
    	int n,a[],b[],opt,set;
    	while(t-->0){
    		n=in.nextInt();
    		String x=in.next();
    		a=new int[n];
    		b=new int[n];
    		opt=0;
    		set=0;
    		fill(a,-1);fill(b,-1);
    		int ind=0;
    		for(int i=0;i<x.length();i++){
    			if(x.charAt(i)=='1'){
    				if(opt==0){a[i]=0;b[i]=1;}
    				else {b[i]=1;a[i]=0;}
    				ind=i;
    				break;
    			}
    			else if(x.charAt(i)=='2'){
    				a[i]=1;b[i]=1;
    			}
    			else {
    				a[i]=0;b[i]=0;
    			}
    		}
    		opt=0;
    		for(int i=ind+1;i<n;i++){
    			if(x.charAt(i)=='2'){
    				if(i-1>=0&&((a[i-1]==0&&b[i-1]==1)||(a[i-1]==1&&b[i-1]==0))){
    					b[i]=0;a[i]=2;
    				}
    			}
    			else if(x.charAt(i)=='1'){
    				a[i]=1;b[i]=0;
    			}
    		}
    		for(int i=0;i<n;i++)
    			if(a[i]==-1){a[i]=1;b[i]=1;}
    		for(int i=0;i<n;i++)
    			app(a[i]);
    		app("\n");
    		for(int i=0;i<n;i++)
    			app(b[i]);
    		app("\n");
    	}
    	pn(ans);
	}
	public static void main(String[] args) throws IOException{
		new Thread(null,new ContestMain(),"Accepted",1<<26).start();
		/* 0_0 I am watching you 0_0 */
	}
	static class Pair<T> implements Comparable<Pair>{
		int l;
		int r;
		Pair(){
			l=0;
			r=0;
		}
		Pair(int k,int v){
			l=k;
			r=v;
		}
		@Override
		public int compareTo(Pair o){
			if(l!=o.l)return (int)(l-o.l);
			return (int)(r-o.r);
		}
		// Fenwick tree question comparator
//        @Override
//        public int compareTo(Pair o) {
//            if(o.r!=r)return (int) (r-o.r);
//            else return (int)(l-o.l);
//        }
	}
	/* BINARY SEARCH FUNCTIONS */
	public static int ceilSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int ceilSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int floorSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	public static int floorSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	/* MODULAR OPERATIONS */
	private static long mod(long a,long b){
	    	return (b+a%b)%b;
	}
	private static long modInv(long a){
	    	return powmod(a,MOD-2);
	}
	private static long powmod(long x,long n){
		if(n==0||x==0)return 1;
		else if(n%2==0)return(powmod((x*x)%MOD,n/2));
		else return (x*(powmod((x*x)%MOD,(n-1)/2)))%MOD;
	}
	public static long mult(long a,long b){
		return mod(mod(a,MOD)*mod(b,MOD),MOD);
	}
	public static long add(long a,long b){
		return mod(mod(a,MOD)+mod(b,MOD),MOD);
	}
	public static long sub(long a,long b){
		return mod(mod(a,MOD)-mod(b,MOD),MOD);
	}
	/* MAX-MIN FUNCTIONS */
	public static long min(long a,long b){
		return Math.min(a, b);
	}
	public static int min(int a,int b){
		return Math.min(a, b);
	}
	public static long max(long a,long b){
		return Math.max(a, b);
	}
	public static int max(int a,int b){
		return Math.max(a, b);
	}
	public static long min(long ar[]){
		return Arrays.stream(ar).min().getAsLong();
	}
	public static int min(int ar[]){
		return Arrays.stream(ar).min().getAsInt();
	}
	public static long max(long ar[]){
		return Arrays.stream(ar).max().getAsLong();
	}
	public static int max(int ar[]){
		return Arrays.stream(ar).max().getAsInt();
	}
	//Reader Class
	static class Reader{
		BufferedReader br;
		StringTokenizer st;
		public Reader(){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;
		}
	}
	//Looping methods
	static void rep(int ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextInt();
	}
	static void rep(long ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextLong();
	}
	static void rep(String ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.next();
	}
	//Printer Methods
	static void pn(Object o){out.print(o);}
	static void pln(Object o){out.println(o);}
	static void pln(){out.println();}
	static void pf(String format,Object o){out.printf(format,o);}
	//Appenders
	static void app(Object o){ans.append(o);}
	static void appn(Object o){ans.append(o+"\n");}
}


/*
 * Remember a 6.72 student can know more than a 10.0 student.
 * Grades don't determine intelligence, they test obedience.
 * I Never Give Up.
 * I will become Candidate Master.
 * I will defeat Saurabh Anand.
 * Skills are Cheap,Passion is Priceless.
 * Obsession is necessary.
 * Author : Sameer Raj
 */
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.Math.*;

import static java.lang.System.out;
import static java.util.Arrays.fill;
import static java.lang.Math.log;
import static java.lang.Math.abs;

public class ContestMain implements Runnable{
	private static Reader in=new Reader();
	private static StringBuilder ans=new StringBuilder();
	private static long MOD=(long)1e9+7;
	private static final int N=(int) (1e5+7); // 1e5+7
    private static ArrayList<Integer> v[]=new ArrayList[N];
	private static boolean mark[]=new boolean[N];
//    private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	/*Not try to hack the sort function*/
	public static void sort(long arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			long temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
	public static void sort(int arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			int temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
    private static long gcd(long a, long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }
    /*Code lies here*/
    @Override
	public void run(){
    	int t=in.nextInt();
    	int n,a[],b[];
    	while(t-->0){
    		n=in.nextInt();
    		String x=in.next();
    		a=new int[n];
    		b=new int[n];
    		fill(a,-1);fill(b,-1);
    		int ind=n;
    		for(int i=0;i<x.length();i++){
    			if(x.charAt(i)=='1'){
    				a[i]=0;b[i]=1;
    				ind=i+1;
    				break;
    			}
    			else if(x.charAt(i)=='2'){
    				a[i]=1;b[i]=1;
    			}
    			else {
    				a[i]=0;b[i]=0;
    			}
    		}
    		for(int i=ind;i<n;i++){
    			if(x.charAt(i)=='2'){
    				b[i]=0;a[i]=2;
    			}
    			else if(x.charAt(i)=='1'){
    				a[i]=1;b[i]=0;
    			}
    			else {a[i]=0;b[i]=0;}
    		}
    		for(int i=0;i<n;i++)
    			if(a[i]==-1){a[i]=1;b[i]=1;}
    		for(int i=0;i<n;i++)
    			app(a[i]);
    		app("\n");
    		for(int i=0;i<n;i++)
    			app(b[i]);
    		app("\n");
    	}
    	pn(ans);
	}
	public static void main(String[] args) throws IOException{
		new Thread(null,new ContestMain(),"Accepted",1<<26).start();
		/* 0_0 I am watching you 0_0 */
	}
	static class Pair<T> implements Comparable<Pair>{
		int l;
		int r;
		Pair(){
			l=0;
			r=0;
		}
		Pair(int k,int v){
			l=k;
			r=v;
		}
		@Override
		public int compareTo(Pair o){
			if(l!=o.l)return (int)(l-o.l);
			return (int)(r-o.r);
		}
		// Fenwick tree question comparator
//        @Override
//        public int compareTo(Pair o) {
//            if(o.r!=r)return (int) (r-o.r);
//            else return (int)(l-o.l);
//        }
	}
	/* BINARY SEARCH FUNCTIONS */
	public static int ceilSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int ceilSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int floorSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	public static int floorSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	/* MODULAR OPERATIONS */
	private static long mod(long a,long b){
	    	return (b+a%b)%b;
	}
	private static long modInv(long a){
	    	return powmod(a,MOD-2);
	}
	private static long powmod(long x,long n){
		if(n==0||x==0)return 1;
		else if(n%2==0)return(powmod((x*x)%MOD,n/2));
		else return (x*(powmod((x*x)%MOD,(n-1)/2)))%MOD;
	}
	public static long mult(long a,long b){
		return mod(mod(a,MOD)*mod(b,MOD),MOD);
	}
	public static long add(long a,long b){
		return mod(mod(a,MOD)+mod(b,MOD),MOD);
	}
	public static long sub(long a,long b){
		return mod(mod(a,MOD)-mod(b,MOD),MOD);
	}
	/* MAX-MIN FUNCTIONS */
	public static long min(long a,long b){
		return Math.min(a, b);
	}
	public static int min(int a,int b){
		return Math.min(a, b);
	}
	public static long max(long a,long b){
		return Math.max(a, b);
	}
	public static int max(int a,int b){
		return Math.max(a, b);
	}
	public static long min(long ar[]){
		return Arrays.stream(ar).min().getAsLong();
	}
	public static int min(int ar[]){
		return Arrays.stream(ar).min().getAsInt();
	}
	public static long max(long ar[]){
		return Arrays.stream(ar).max().getAsLong();
	}
	public static int max(int ar[]){
		return Arrays.stream(ar).max().getAsInt();
	}
	//Reader Class
	static class Reader{
		BufferedReader br;
		StringTokenizer st;
		public Reader(){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;
		}
	}
	//Looping methods
	static void rep(int ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextInt();
	}
	static void rep(long ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextLong();
	}
	static void rep(String ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.next();
	}
	//Printer Methods
	static void pn(Object o){out.print(o);}
	static void pln(Object o){out.println(o);}
	static void pln(){out.println();}
	static void pf(String format,Object o){out.printf(format,o);}
	//Appenders
	static void app(Object o){ans.append(o);}
	static void appn(Object o){ans.append(o+"\n");}
}


//
//  main.cpp
//  To Add Or Not To Add again
//
//  Created by Vivek Pratap Deo on 11/01/19.
//  Copyright © 2019 Vivek Pratap Deo. All rights reserved.
//
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n,k,number;
vector<ll> a,sum(100005,0);
ll check(ll cnt)
{
   // ll ret=-1;
   // pair<ll, ll> ans;
   // ll ans=0;
    for(ll i=cnt;i<=n;i++)
    {
        ll s=a[i]*cnt-(sum[i]-sum[i-cnt]);
        if(s<=k)
        {
            number=a[i];
            return 1;
        }
    }
    return 0;
}
//pair<ll, ll> finans;
ll binsch(ll low,ll high)
{
    while(low<high)
    {
        ll mid=(low+high+1)/2;
       // pair<ll, ll> ans=check(mid);
        if(check(mid))
        {
            low=mid;
            //finans=ans;
        }
        else
        {
            high=mid-1;
        }
    }
    return low;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    a.push_back(0);
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        a.push_back(x);
        //sum.push_back(0);
    }
    sort(a.begin(), a.end());
   // sum[0]=a[0];
    for(ll i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=binsch(1, n);
    cout<<ans<<" "<<number;
}


//
//  main.cpp
//  To Add Or Not To Add again
//
//  Created by Vivek Pratap Deo on 11/01/19.
//  Copyright © 2019 Vivek Pratap Deo. All rights reserved.
//
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n,k,number;
ll a[100005],sum[100005];
ll check(ll cnt)
{
   // ll ret=-1;
   // pair<ll, ll> ans;
   // ll ans=0;
    for(ll i=cnt;i<=n;i++)
    {
        ll s=a[i]*cnt-(sum[i]-sum[i-cnt]);
        if(s<=k)
        {
            number=a[i];
            return 1;
        }
    }
    return 0;
}
//pair<ll, ll> finans;
ll binsch(ll low,ll high)
{
    while(low<high)
    {
        ll mid=(low+high+1)/2;
       // pair<ll, ll> ans=check(mid);
        if(check(mid))
        {
            low=mid;
            //finans=ans;
        }
        else
        {
            high=mid-1;
        }
    }
    return low;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    //a.push_back(-1000000007);
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i]
        //sum.push_back(0);
    }
    sort(a+1, a+n+1);
   // sum[0]=a[0];
    //sum[1]=a[1];
    for(ll i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=binsch(1, n);
    cout<<ans<<" "<<number;
}


//
//  main.cpp
//  To Add Or Not To Add again
//
//  Created by Vivek Pratap Deo on 11/01/19.
//  Copyright © 2019 Vivek Pratap Deo. All rights reserved.
//
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n,k,number;
vector<ll> a,sum(100005,0);
ll check(ll cnt)
{
   // ll ret=-1;
   // pair<ll, ll> ans;
    ll ans=0;
    for(ll i=cnt;i<=n;i++)
    {
        ll s=a[i]*cnt-(sum[i]-sum[i-cnt]);
        if(s<=k)
        {
            number=a[i];
            ans=1;
        }
    }
    return ans;
}
//pair<ll, ll> finans;
ll binsch(ll low,ll high)
{
    while(low<high)
    {
        ll mid=(low+high+1)/2;
       // pair<ll, ll> ans=check(mid);
        if(check(mid))
        {
            low=mid;
            //finans=ans;
        }
        else
        {
            high=mid-1;
        }
    }
    return low;
}
int main(int argc, const char * argv[]) {
        ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    a.push_back(0);
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        a.push_back(x);
        //sum.push_back(0);
    }
    sort(a.begin(), a.end());
   // sum[0]=a[0];
    for(ll i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=binsch(1, n);
    cout<<ans<<" "<<number;
}


//
//  main.cpp
//  To Add Or Not To Add again
//
//  Created by Vivek Pratap Deo on 11/01/19.
//  Copyright © 2019 Vivek Pratap Deo. All rights reserved.
//
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n,k,number;
vector<ll> a,sum(100005,0);
ll check(ll cnt)
{
   // ll ret=-1;
   // pair<ll, ll> ans;
   // ll ans=0;
    for(ll i=cnt;i<=n;i++)
    {
        ll s=a[i]*cnt-(sum[i]-sum[i-cnt]);
        if(s<=k)
        {
            number=a[i];
            return 1;
        }
    }
    return 0;
}
//pair<ll, ll> finans;
ll binsch(ll low,ll high)
{
    while(low<high)
    {
        ll mid=(low+high+1)/2;
       // pair<ll, ll> ans=check(mid);
        if(check(mid))
        {
            low=mid;
            //finans=ans;
        }
        else
        {
            high=mid-1;
        }
    }
    return low;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    a.push_back(-1000000007);
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        a.push_back(x);
        //sum.push_back(0);
    }
    sort(a.begin(), a.end());
   // sum[0]=a[0];
    sum[1]=a[1];
    for(ll i=2;i<=n;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=binsch(1, n);
    cout<<ans<<" "<<number;
}


//
//  main.cpp
//  To Add Or Not To Add again
//
//  Created by Vivek Pratap Deo on 11/01/19.
//  Copyright © 2019 Vivek Pratap Deo. All rights reserved.
//
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n,k,number;
vector<ll> a,sum(100005,0);
ll check(ll cnt)
{
   // ll ret=-1;
   // pair<ll, ll> ans;
   // ll ans=0;
    for(ll i=cnt;i<=n;i++)
    {
        ll s=a[i]*cnt-(sum[i]-sum[i-cnt]);
        if(s<=k)
        {
            number=a[i];
            return 1;
        }
    }
    return 0;
}
//pair<ll, ll> finans;
ll binsch(ll low,ll high)
{
    while(low<high)
    {
        ll mid=(low+high+1)/2;
       // pair<ll, ll> ans=check(mid);
        if(check(mid))
        {
            low=mid;
            //finans=ans;
        }
        else
        {
            high=mid-1;
        }
    }
    return low;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    a.push_back(-1000000007);
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        a.push_back(x);
        //sum.push_back(0);
    }
    sort(a.begin(), a.end());
   // sum[0]=a[0];
    for(ll i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=binsch(1, n);
    cout<<ans<<" "<<number;
}


//
//  main.cpp
//  to add or not to add
//
//  Created by Vivek Pratap Deo on 03/11/18.
//  Copyright © 2018 Vivek Pratap Deo. All rights reserved.
//
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(int argc, const char * argv[]) {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a.rbegin(), a.rend());
    ll ans=1;
    ll i=1;
    while(1)
    {
        //cout<<i<<" "<<ans<<" "<<k<<endl;

        if(a[0]-a[i]<=k)
        {
            ans++;
            k-=a[0]-a[i];
            i++;
        }
        else
        {
            break;
        }
        if(i==n)
            break;
    }
    //cout<<k<<endl;
    ll fin=a[0];
    ll maxs=ans;
    ll j=1;
    ans-=1;
    k+=a[0]-a[1];
    //cout<<maxs<<" "<<fin<<endl;
    while(i<n)
    {
        //cout<<k<<" "<<i<<" "<<ans<<endl;
        if(i<j)
        {
            i=j;
        }
      if(k>=(a[j]-a[i]))
      {
          k-=(a[j]-a[i]);
          i++;
          ans++;
      }
      else
      {
          k+=a[j]-a[j+1];
          if(ans>=maxs)
          {
              maxs=ans;
              fin=a[j];
          }
          ans-=1;
          j++;
      }
        if(i==n)
        {
            if(ans>=maxs)
            {
                maxs=ans;
                fin=a[j];
            }
        }
    }
    cout<<maxs<<" "<<fin;
}


#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
const long long int MAXN = 2*(1e5+5);
const long long int MINN = 1e2;
const long long int inf = 1e9+9;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stack<int> st;
ll n,k,a[MAXN],sum[MAXN],a1,a2;
int main(){
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    DRACARYS
    cin>>n>>k;
    repA(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    repA(i,1,n) sum[i]=sum[i-1]+a[i];
    repA(i,1,n){
        ll x=1;
        while(a[i]*(i-x+1)-(sum[i]-sum[x-1])>k){
                ++x;
        }
        if(i-x+1>a1){
            a1=i-x+1;
            a2=a[i];
        }
    }
    cout<<a1<<" "<<a2<<endl;
    return 0;
}


#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
const long long int MAXN = 2*(1e5+5);
const long long int MINN = 1e2;
const long long int inf = 1e9+9;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stack<int> st;
ll n,k,a[MAXN],sum[MAXN],a1,a2;
int main(){
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    DRACARYS
    scanf("%lld %lld",&n,&k);
    repA(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    repA(i,1,n) sum[i]=sum[i-1]+a[i];
    repA(i,1,n){
        int x=1;
        while(a[i]*(i-x+1)-(sum[i]-sum[x-1])>k){
                ++x;
        }
        if(i-x+1>a1){
            a1=i-x+1;
            a2=a[i];
        }
    }
    cout<<a1<<" "<<a2<<endl;
    return 0;
}


#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
const long long int MAXN = 2*(1e5+5);
const long long int MINN = 1e2;
const long long int inf = 1e9+9;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stack<int> st;
ll n,k,a[MAXN],sum[MAXN],a1,a2;
int main(){
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    //DRACARYS
    scanf("%I64d%I64d", &n, &k);
    repA(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    repA(i,1,n) sum[i]=sum[i-1]+a[i];
    repA(i,1,n){
        int x=1;
        while(a[i]*(i-x+1)-(sum[i]-sum[x-1])>k){
                ++x;
        }
        if(i-x+1>a1){
            a1=i-x+1;
            a2=a[i];
        }
    }
    cout<<a1<<" "<<a2<<endl;
    return 0;
}


#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
const long long int MAXN = 2*(1e5+5);
const long long int MINN = 1e2;
const long long int inf = 1e9+9;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stack<int> st;
ll n,k,a[MAXN],sum[MAXN],a1,a2;
int main(){
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    DRACARYS
    cin>>n>>k;
    repA(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    repA(i,1,n) sum[i]=sum[i-1]+a[i];
    repA(i,1,n){
        int x=1;
        while(a[i]*(i-x+1)-(sum[i]-sum[x-1])>k){
                ++x;
        }
        if(i-x+1>a1){
            a1=i-x+1;
            a2=a[i];
        }
    }
    cout<<a1<<" "<<a2<<endl;
    return 0;
}


#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
const long long int MAXN = 2*(1e5+5);
const long long int MINN = 1e2;
const long long int inf = 1e9+9;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stack<int> st;
ll n,k,a[MAXN],sum[MAXN],a1,a2;
int main(){
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    DRACARYS
    scanf("%I64d%I64d", &n, &k);
    repA(i,1,n) cin>>a[i];
    sort(a+1,a+n+1);
    repA(i,1,n) sum[i]=sum[i-1]+a[i];
    repA(i,1,n){
        int x=1;
        while(a[i]*(i-x+1)-(sum[i]-sum[x-1])>k){
                ++x;
        }
        if(i-x+1>a1){
            a1=i-x+1;
            a2=a[i];
        }
    }
    cout<<a1<<" "<<a2<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 2e5;
ll n, k, a[N], sum[N], mx, ans;

int main(){
    scanf("%I64d%I64d", &n, &k);
    for(int i = 1; i <= n; i++)
        scanf("%I64d", &a[i]);
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + a[i];
    for(int i = 1, l = 1; i <= n; i++){
        while(a[i] * (i - l + 1) - sum[i] + sum[l - 1] > k)
            l++;
        if(i - l + 1 > mx){
            mx = i - l + 1, ans = a[i];
        }
    }
    cout << mx << " " << ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5+100;
int a[N];
ll s[N];
int n;ll k;
int solve(int p){
    int l = 0,r = p;
    while(l<r){
        int m = (l+r+1)>>1;
        if((ll)m*a[p] - (s[p]-s[p-m]) <= k)l = m;
        else r = m-1;
    }
    return l+1;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;++i){
        s[i+1] = s[i] + a[i];
    }
    int ans = 0;
    int now,sol;
    for(int i=0;i<n;++i){
        now = solve(i);
        if(now>ans){
            ans = now;
            sol = a[i];
        }
    }
    cout<<ans<<" "<<sol<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
int a[N];
int s[N];
int n;
ll k;
int solve(int p){
    int l=0,r = p;
    while(l<r){
        int m = (l+r+1)>>1;
        if((ll)m*a[p]-(s[p]-s[p-m])<=k)l = m;
        else r = m-1;
    }
    return l+1;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;++i)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;++i)s[i+1] = s[i] + a[i];
    int ans = 0,sol = 0;
    for(int i=0;i<n;++i){
        int ma = solve(i);
        if(ma > ans)ans = ma,sol = a[i];
    }
    cout<<ma<<" "<<sol<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5+100;
int a[N];
int s[N];
int n;ll m;
int solve(int p){
    int l = 0,r = p;
    while(l<r){
        int m = (l+r+1)>>1;
        if((ll)m*a[p] - (s[p]-s[p-m]) <= k)l = m;
        else r = m-1;
    }
    return l+1;
}
int main(){
    cin>>n>>m;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;++i){
        s[i+1] = s[i] + a[i];
    }
    int ans = 0;
    int now,sol;
    for(int i=0;i<n;++i){
        now = solve(i);
        if(now>ans){
            ans = now;
            sol = a[i];
        }
    }
    cout<<ans<<" "<<sol<<"\n";
    return 0;
}


   /**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a  loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
#ifndef _GLIbCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplu >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <cstring>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include<random>
#include <chrono>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplu >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#endif
#define __ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
// #define INF 0x7f7f7f7f
#define ull unsigned long long int
#define pii pair<int,int>
#define ll long long int
#define ld long double
#define MSET(x,y) memset(x,y,sizeof(x))
// #define l long
#define se second
#define AlphaSize 26
#define fi first
#define NIL 0
#define UNVISITED -1
#define EXPOLORED 0
#define mk make_pair
#define pb push_back
#define sc(n) scanf("%d",&n)
#define NIL 0
#define db double
#define pii pair<int,int>
#define eps 1e-8
#define inrange(x,y,n,m) ((x>=1 && y>=1 && x<=n && y<=m))
#define all(x) x.begin(),x.end()
#define me(u,v,w) make_pair(w,make_pair(u,v))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define foreach(e, x) for(__typeof(x.begin()) e = x.begin(); e != x.end(); ++ e)
// #define add(a,b) (a + b >= MOD ? a+b-MOD:a+b)
#define hs(c1,c2) (256*min(c1,c2) + max(c1,c2))
typedef struct{ int sum,suf,pre,max;} Node;
int toint(const string &s) { stringstream ss; ss << s; int x; ss >> x; return x; }
const int MAXN = 2e5+100;
const int UP = 31;
// const ll inf = 1e18;
// const int mod = 1e9+7;
const ll highest = 1e18;
// const int inf = 1e9+10;
// const dou    ble pi = 3.141592653589793238462643383;
const double pi = acos(-1);
const double Phi =  1.618033988749894;
const int logn = 20;
const double root5 = 2.236067977;
const ll inf64=1e16;
// const int mod = 1e9+7;
const int ini = -1e9;
/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
const int N = 1e5+100;
int n,k,a[N];
ll s[N];
int solve(int p){
    int l=0,r=p;
    while ( l<r ) {
        int m=(l+r+1)/2;
        if ( (ll)m*a[p]-(s[p]-s[p-m])<=k ) l=m;
        else r=m-1;
    }
    return l+1;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    // cout<<"J9\n";
    sort(a,a+n);
    for(int i=0;i<n;++i){
        s[i+1] = s[i] + a[i];
    }
    // cout<<"H\n";
    int ans=0,sol=0;
    for ( int i=0; i<n; i++ ) {
        int now=solve(i);
        if ( now>ans ) ans=now,sol=a[i];
    }
    // cout<<"H\n";
    printf("%d %d\n",ans,sol);
    // cout<<ans<<" "<<sol<<"\n";
}
// struct bigint {
//     vector<int> z;
//     int sign;

//     bigint() :
//         sign(1) {
//     }

//     bigint(long v) {
//         *this = v;
//     }

//     bigint(const string &s) {
//         read(s);
//     }

//     void operator=(const bigint &v) {
//         sign = v.sign;
//         z = v.z;tor=(long long v) {
//         sign = 1;
//         if (v < return 0;0)
//             sign = -1, v = -v;
//         z.clear();
//         for (; v > 0; v = v / base)
//             z.push_back(v % base);
//     }

//     bigint operator+(const bigint &v) const {
//         if (sign == v.sign) {
//             bigint res = v;

//             for (int i = 0, carry = 0; i < (int) max(z.size(), v.z.size()) || carry; ++i) {
//                 if (i == (int) res.z.size())
//                     res.z.push_back(0);
//                 res.z[i] += carry + (i < (int) z.size() ? z[i] : 0);
//                 carry = res.z[i] >= base;
//                 if (carry)
//                     res.z[i] -= base;
//             }
//             return res;
//         }
//         return *this - (-v);
//     }

//     bigint operator-(const bigint &v) const {
//         if (sign == v.sign) {
//             if (abs() >= v.abs()) {
//                 bigint res = *this;
//                 for (int i = 0, carry = 0; i < (int) v.z.size() || carry; ++i) {
//                     res.z[i] -= carry + (i < (int) v.z.size() ? v.z[i] : 0);
//                     carry = res.z[i] < 0;
//                     if (carry)
//                         res.z[i] += base;
//                 }
//                 res.trim();
//                 return res;
//             }
//             return -(v - *this);
//         }
//         return *this + (-v);
//     }

//     void operator*=(int v) {
//         if (v < 0)
//             sign = -sign, v = -v;
//         for (int i = 0, carry = 0; i < (int) z.size() || carry; ++i) {
//             if (i == (int) z.size())
//                 z.push_back(0);
//             long long cur = z[i] * (long long) v + carry;
//             carry = (int) (cur / base);
//             z[i] = (int) (cur % base);
//             //asm("divl %%ecx" : "=a"(carry), "=d"(a[i]) : "A"(cur), "c"(base));
//         }
//         trim();
//     }

//     bigint operator*(int v) const {
//         bigint res = *this;
//         res *= v;
//         return res;
//     }

//     friend pair<bigint, bigint> divmod(const bigint &a1, const bigint &b1) {
//         int norm = base / (b1.z.back() + 1);
//         bigint a = a1.abs() * norm;
//         bigint b = b1.abs() * norm;
//         bigint q, r;
//         q.z.resize(a.z.size());

//         for (int i = a.z.size() - 1; i >= 0; i--) {
//             r *= base;
//             r += a.z[i];
//             int s1 = b.z.size() < r.z.size() ? r.z[b.z.size()] : 0;
//             int s2 = b.z.size() - 1 < r.z.size() ? r.z[b.z.size() - 1] : 0;
//             int d = ((long long) s1 * base + s2) / b.z.back();
//             r -= b * d;
//             while (r < 0)
//                 r += b, --d;
//             q.z[i] = d;
//         }

//         q.sign = a1.sign * b1.sign;
//         r.sign = a1.sign;
//         q.trim();
//         r.trim();
//         return make_pair(q, r / norm);
//     }

//     friend bigint sqrt(const bigint &a1) {
//         bigint a = a1;
//         while (a.z.empty() || a.z.size() % 2 == 1)
//             a.z.push_back(0);

//         int n = a.z.size();

//         int firstDigit = (int) sqrt((double) a.z[n - 1] * base + a.z[n - 2]);
//         int norm = base / (firstDigit + 1);
//         a *= norm;
//         a *= norm;
//         while (a.z.empty() || a.z.size() % 2 == 1)
//             a.z.push_back(0);

//         bigint r = (long long) a.z[n - 1] * base + a.z[n - 2];
//         firstDigit = (int) sqrt((double) a.z[n - 1] * base + a.z[n - 2]);
//         int q = firstDigit;
//         bigint res;

//         for(int j = n / 2 - 1; j >= 0; j--) {
//             for(; ; --q) {
//                 bigint r1 = (r - (res * 2 * base + q) * q) * base * base + (j > 0 ? (long long) a.z[2 * j - 1] * base + a.z[2 * j - 2] : 0);
//                 if (r1 >= 0) {
//                     r = r1;
//                     break;
//                 }
//             }
//             res *= base;
//             res += q;

//             if (j > 0) {
//                 int d1 = res.z.size() + 2 < r.z.size() ? r.z[res.z.size() + 2] : 0;
//                 int d2 = res.z.size() + 1 < r.z.size() ? r.z[res.z.size() + 1] : 0;
//                 int d3 = res.z.size() < r.z.size() ? r.z[res.z.size()] : 0;
//                 q = ((long long) d1 * base * base + (long long) d2 * base + d3) / (firstDigit * 2);
//             }
//         }

//         res.trim();
//         return res / norm;
//     }

//     bigint operator/(const bigint &v) const {
//         return divmod(*this, v).first;
//     }

//     bigint operator%(const bigint &v) const {
//         return divmod(*this, v).second;
//     }

//     void operator/=(int v) {
//         if (v < 0)
//             sign = -sign, v = -v;
//         for (int i = (int) z.size() - 1, rem = 0; i >= 0; --i) {
//             long long cur = z[i] + rem * (long long) base;
//             z[i] = (int) (cur / v);
//             rem = (int) (cur % v);
//         }
//         trim();
//     }

//     bigint operator/(int v) const {
//         bigint res = *this;
//         res /= v;
//         return res;
//     }

//     int operator%(int v) const {
//         if (v < 0)
//             v = -v;
//         int m = 0;
//         for (int i = z.size() - 1; i >= 0; --i)
//             m = (z[i] + m * (long long) base) % v;
//         return m * sign;
//     }

//     void operator+=(const bigint &v) {
//         *this = *this + v;
//     }
//     void operator-=(const bigint &v) {
//         *this = *this - v;
//     }
//     void operator*=(const bigint &v) {
//         *this = *this * v;
//     }
//     void operator/=(const bigint &v) {
//         *this = *this / v;
//     }

//     bool operator<(const bigint &v) const {
//         if (sign != v.sign)
//             return sign < v.sign;
//         if (z.size() != v.z.size())
//             return z.size() * sign < v.z.size() * v.sign;
//         for (int i = z.size() - 1; i >= 0; i--)
//             if (z[i] != v.z[i])
//                 return z[i] * sign < v.z[i] * sign;
//         return false;
//     }

//     bool operator>(const bigint &v) const {
//         return v < *this;
//     }
//     bool operator<=(const bigint &v) const {
//         return !(v < *this);
//     }
//     bool operator>=(const bigint &v) const {
//         return !(*this < v);
//     }
//     bool operator==(const bigint &v) const {
//         return !(*this < v) && !(v < *this);
//     }
//     bool operator!=(const bigint &v) const {
//         return *this < v || v < *this;
//     }

//     void trim() {
//         while (!z.empty() && z.back() == 0)
//             z.pop_back();
//         if (z.empty())
//             sign = 1;
//     }

//     bool isZero() const {
//         return z.empty() || (z.size() == 1 && !z[0]);
//     }

//     bigint operator-() const {
//         bigint res = *this;
//         res.sign = -sign;
//         return res;
//     }

//     bigint abs() const {
//         bigint res = *this;
//         res.sign *= res.sign;
//         return res;
//     }

//     long long longValue() const {
//         long long res = 0;
//         for (int i = z.size() - 1; i >= 0; i--)
//             res = res * base + z[i];
//         return res * sign;
//     }

//     friend bigint gcd(const bigint &a, const bigint &b) {
//         return b.isZero() ? a : gcd(b, a % b);
//     }
//     friend bigint lcm(const bigint &a, const bigint &b) {
//         return a / gcd(a, b) * b;
//     }

//     void read(const string &s) {
//         sign = 1;
//         z.clear();
//         int pos = 0;
//         while (pos < (int) s.size() && (s[pos] == '-' || s[pos] == '+')) {
//             if (s[pos] == '-')
//                 sign = -sign;
//             ++pos;
//         }
//         for (int i = s.size() - 1; i >= pos; i -= base_digits) {
//             int x = 0;
//             for (int j = max(pos, i - base_digits + 1); j <= i; j++)
//                 x = x * 10 + s[j] - '0';
//             z.push_back(x);
//         }
//         trim();
//     }

//     friend istream& operator>>(istream &stream, bigint &v) {
//         string s;
//         stream >> s;
//         v.read(s);
//         return stream;
//     }

//     friend ostream& operator<<(ostream &stream, const bigint &v) {
//         if (v.sign == -1)
//             stream << '-';
//         stream << (v.z.empty() ? 0 : v.z.back());
//         for (int i = (int) v.z.size() - 2; i >= 0; --i)
//             stream << setw(base_digits) << setfill('0') << v.z[i];
//         return stream;
//     }

//     static vector<int> convert_base(const vector<int> &a, int old_digits, int new_digits) {
//         vector<long long> p(max(old_digits, new_digits) + 1);
//         p[0] = 1;
//         for (int i = 1; i < (int) p.size(); i++)
//             p[i] = p[i - 1] * 10;
//         vector<int> res;
//         long long cur = 0;
//         int cur_digits = 0;
//         for (int i = 0; i < (int) a.size(); i++) {
//             cur += a[i] * p[cur_digits];
//             cur_digits += old_digits;
//             while (cur_digits >= new_digits) {
//                 res.push_back(int(cur % p[new_digits]));
//                 cur /= p[new_digits];
//                 cur_digits -= new_digits;
//             }
//         }
//         res.push_back((int) cur);
//         while (!res.empty() && res.back() == 0)
//             res.pop_back();
//         return res;
//     }

//     typedef vector<long long> vll;

//     static vll karatsubaMultiply(const vll &a, const vll &b) {
//         int n = a.size();
//         vll res(n + n);
//         if (n <= 32) {
//             for (int i = 0; i < n; i++)
//                 for (int j = 0; j < n; j++)
//                     res[i + j] += a[i] * b[j];
//             return res;
//         }

//         int k = n >> 1;
//         vll a1(a.begin(), a.begin() + k);
//         vll a2(a.begin() + k, a.end());
//         vll b1(b.begin(), b.begin() + k);
//         vll b2(b.begin() + k, b.end());

//         vll a1b1 = karatsubaMultiply(a1, b1);
//         vll a2b2 = karatsubaMultiply(a2, b2);

//         for (int i = 0; i < k; i++)
//             a2[i] += a1[i];
//         for (int i = 0; i < k; i++)
//             b2[i] += b1[i];

//         vll r = karatsubaMultiply(a2, b2);
//         for (int i = 0; i < (int) a1b1.size(); i++)
//             r[i] -= a1b1[i];
//         for (int i = 0; i < (int) a2b2.size(); i++)
//             r[i] -= a2b2[i];

//         for (int i = 0; i < (int) r.size(); i++)
//             res[i + k] += r[i];
//         for (int i = 0; i < (int) a1b1.size(); i++)
//             res[i] += a1b1[i];
//         for (int i = 0; i < (int) a2b2.size(); i++)
//             res[i + n] += a2b2[i];
//         return res;
//     }

//     bigint operator*(const bigint &v) const {
//         vector<int> a6 = convert_base(this->z, base_digits, 6);
//         vector<int> b6 = convert_base(v.z, base_digits, 6);
//         vll a(a6.begin(), a6.end());
//         vll b(b6.begin(), b6.end());
//         while (a.size() < b.size())
//             a.push_back(0);
//         while (b.size() < a.size())
//             b.push_back(0);
//         while (a.size() & (a.size() - 1))
//             a.push_back(0), b.push_back(0);
//         vll c = karatsubaMultiply(a, b);
//         bigint res;
//         res.sign = sign * v.sign;
//         for (int i = 0, carry = 0; i < (int) c.size(); i++) {
//             long long cur = c[i] + carry;
//             res.z.push_back((int) (cur % 1000000));
//             carry = (int) (cur / 1000000);
//         }
//         res.z = convert_base(res.z, 6, base_digits);
//         res.trim();
//         return res;
//     }
// };


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5+100;
int a[N];
int s[N];
int n;ll k;
int solve(int p){
    int l = 0,r = p;
    while(l<r){
        int m = (l+r+1)>>1;
        if((ll)m*a[p] - (s[p]-s[p-m]) <= k)l = m;
        else r = m-1;
    }
    return l+1;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;++i){
        s[i+1] = s[i] + a[i];
    }
    int ans = 0;
    int now,sol;
    for(int i=0;i<n;++i){
        now = solve(i);
        if(now>ans){
            ans = now;
            sol = a[i];
        }
    }
    cout<<ans<<" "<<sol<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5+100;
int a[N];
int s[N];
int n;
ll k;
int solve(int p){
    int l=0,r = p;
    while(l<r){
        int m = (l+r+1)>>1;
        if((ll)m*a[p]-(s[p]-s[p-m])<=k)l = m;
        else r = m-1;
    }
    return l+1;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;++i)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;++i)s[i+1] = s[i] + a[i];
    int ans = 0,sol = 0;
    int ma;
    for(int i=0;i<n;++i){
        ma = solve(i);
        if(ma > ans)ans = ma,sol = a[i];
    }
    cout<<ma<<" "<<sol<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
int a[N];
int s[N];
int n;ll m;
int solve(int p){
    int l = 0,r = p;
    while(l<r){
        int m = (l+r+1)>>1;
        if((ll)m*a[p] - (s[p]-s[p-m]) <= k)l = m;
        else r = m-1;
    }
    return l+1;
}
int main(){
    cin>>n>>m;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;++i){
        s[i+1] = s[i] + a[i];
    }
    int ans = 0;
    int now,sol;
    for(int i=0;i<n;++i){
        now = solve(i);
        if(now>ans){
            ans = now;
            sol = a[i];
        }
    }
    cout<<ans<<" "<<sol<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int mxN = 1e5+10;
vector<long long int> a, pref;
int n, k;
int binarySearch(int low, int high){
    int pivot = high;
    int answer = -1;
    while(high >= low){
        int mid = (high + low)/2;
        long long int required = (pivot - mid + 1LL)*a[pivot] - (pref[pivot] - pref[mid-1]);
        if(required <= (long long int)k){
            answer = mid;
            high = mid - 1;
        }
        else{
            low = mid + 1;
        }
    }
    return answer;
}
int main(){
    cin >> n >> k;
    a.resize(n+1);
    pref.resize(n+1);
    a[0] = -1e9-1;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = 1; i <= n; i++){
        pref[i] = pref[i-1] + a[i];
    }
    int len = 1;
    long long int best = a[1];
    for(int i = 1; i <= n; i++){
        int curr = binarySearch(1, i);
       if(curr == -1){
           curr = 1;
       }
       else{
           curr = i - curr + 1;
       }
        if(curr > len){
            len = curr;
            best = a[i];
        }
    }
    cout << len << " " << best << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int mxN = 1e5+10;
vector<long long int> a;
int n, k;
bool isPossible(int mid, int index){
    long long int needed = 0LL;
    for(int i = mid; i <= index; i++){
        needed += (a[index] - a[i]);
        if(needed > k){
            return false;
        }
    }
    return needed <= k;
}
int binarySearch(int low, int high, int index){
    int answer = 1;
    int start = high;
    long long int There = (long long int)k;
    while(high >= low){
        int mid = (high + low)/2;
        if(isPossible(mid, index)){
            answer = start - mid + 1;
            high = mid - 1;
        }
        else{
            low = mid + 1;
        }
    }
    return answer;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int len = 1;
    long long int best = a[0];
    for(int i = 1; i < n; i++){
        int pos = binarySearch(0, i, i);
        if(len < pos){
            len = pos;
            best = a[i];
        }
    }
    cout << len << " " << best << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int mxN = 1e5+10;
vector<long long int> a;
int n, k;
int binarySearch(int low, int high, long long int val){
    int answer = 0;
    long long int There = (long long int)k;
    while(high >= low){
        int needed = (val - a[high]);
        if(needed > There){
            return answer;
        }
        There -= needed;
        answer++;
        high--;
    }
    return answer;
}
int main(){
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int len = 1;
    long long int best = a[0];
    for(int i = 1; i < n; i++){
        int pos = binarySearch(0, i, a[i]);
        if(len < pos){
            len = pos;
            best = a[i];
        }
    }
    cout << len << " " << best << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int mxN = 1e5+10;
vector<long long int> a;
int n, k;
bool isPossible(int mid, int index){
    long long int needed = 0LL;
    for(int i = mid; i <= index; i++){
        needed += (a[index] - a[i]);
    }
    return needed <= k;
}
int binarySearch(int low, int high, int index){
    int answer = 1;
    int start = high;
    long long int There = (long long int)k;
    while(high >= low){
        int mid = (high + low)/2;
        if(isPossible(mid, index)){
            answer = start - mid + 1;
            high = mid - 1;
        }
        else{
            low = mid + 1;
        }
    }
    return answer;
}
int main(){
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int len = 1;
    long long int best = a[0];
    for(int i = 1; i < n; i++){
        int pos = binarySearch(0, i, i);
        if(len < pos){
            len = pos;
            best = a[i];
        }
    }
    cout << len << " " << best << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int mxN = 1e5+10;
vector<long long int> a;
int n, k;
bool isPossible(int mid, int index){
    long long int needed = 0LL;
    for(int i = mid; i <= index; i++){
        needed += (a[index] - a[i]);
        if(needed > k){
            return false;
        }
    }
    return needed <= k;
}
int binarySearch(int low, int high, int index){
    int answer = 1;
    int start = high;
    long long int There = (long long int)k;
    while(high >= low){
        int mid = (high + low)/2;
        if(isPossible(mid, index)){
            answer = start - mid + 1;
            high = mid - 1;
        }
        else{
            low = mid + 1;
        }
    }
    return answer;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int len = 1;
    long long int best = a[0];
    for(int i = n-1; i >= 1; i--){
        int pos = binarySearch(0, i, i);
        if(len < pos){
            len = pos;
            best = a[i];
        }
        if(len >= i){
            break;
        }
    }
    cout << len << " " << best << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,k; cin>>n>>k;
	ll arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	ll ans = 0;
	ll ind = -1;
	for(int i = 1; i < n; i++){
		ll tt = k;
		ll xx = 0;
		for(int j = i-1; j >= 0; j--){
			if(arr[j] < arr[i]){
				if((arr[i]-arr[j]) > 0) {
					tt -= (arr[i]-arr[j]);
					if(tt >= 0) xx++;
				}
			}
		}
		ll co = 0;
		for(int j = 0; j < n; j++) if(arr[i] == arr[j]) co++;
		if((xx+co) > ans){
			ans = (xx+co);
			ind = arr[i];
		}
	}
	if(ans > 1) cout<<ans<<" "<<ind<<"\n";
	else cout<<1<<" "<<arr[0]<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,k; cin>>n>>k;
	ll arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	ll ans = 0;  ll ind = -1;
	for(int i = 1; i < n; i++){
		ll tt = k;
		ll xx = 0;
		for(int j = i-1; j >= 0; j--){
			if(arr[j] <= arr[i]){
				if((arr[i]-arr[j]) >= 0) {
					tt -= (arr[i]-arr[j]);
					if(tt >= 0) xx++;
					else break;
				}
			}
		}
		if((xx+1) > ans){
			ans = (xx+1);
			ind = arr[i];
		}
	}
	if(ans > 1) cout<<ans<<" "<<ind<<"\n";
	else cout<<1<<" "<<arr[0]<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n,k;
	cin>>n>>k;
	long long arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	long long c;
	long long  best = 0;
	long long  ind;
	int prev = -1;
	for(int i = 0; i <  n; i++){
		c = k;
		long long  ans = 0;
		for(int j = i-1; j >= 0; j--){
			if(c >= (arr[i]-arr[j])){
				c -= arr[i]-arr[j];
				ans++;
			}
			else break;
		}
		//cout<<prev<<" "<<ans<<"\n";
		if(ans >= prev){
			prev = ans;
		}
		else break;
		if(ans > best){
			ind = arr[i];
			best = ans;
		}
	}
	cout<<best+1<<" "<<ind<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	long long arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	long long c;
	long long  best = 0;
	long long  ind;
	for(int i = 0; i <  n; i++){
		c = k;
		long long  ans = 0;
		for(int j = i-1; j >= 0; j--){
			if(c >= (arr[i]-arr[j])){
				c -= arr[i]-arr[j];
				ans++;
			}
			else break;
		}
		if(ans > best){
			ind = arr[i];
			best = ans;
		}
	}
	cout<<best+1<<" "<<ind<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	long long arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	long long c;
	long long  best = 0;
	long long  ind;
	for(int i = 0; i <  n; i++){
		c = k;
		long long  ans = 0;
		for(int j = i-1; j >= 0; j--){
			if(c >= (arr[i]-arr[j])){
				c -= arr[i]-arr[j];
				ans++;
			}
		}
		if(ans > best){
			ind = arr[i];
			best = ans;
		}
	}
	cout<<best+1<<" "<<ind<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,k; cin>>n>>k;
	ll arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	int pre[n]; pre[0] = arr[0]; for(int i = 1; i <  n; i++) pre[i] = pre[i-1]+arr[i];
	ll ans = 0;  ll ind = -1;
	for(int i = 1; i < n; i++){
		int l = 0;
		int r = i;
		int good = 0;
		while(l <= r){
			int mid = l + (r-l)/2;
			if((arr[i]*((i-mid)))- (pre[i-1]-pre[mid-1]) <= k){
				good = (i-mid)+1;
				r = mid-1;
			}
			else l = mid+1;
		}
		if(good > ans){
			ans = good;
			ind = arr[i];
		}
	}
	if(ans > 1) cout<<ans<<" "<<ind<<"\n";
	else cout<<1<<" "<<arr[0]<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,k; cin>>n>>k;
	ll arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	ll ans = 0;  ll ind = -1;
	for(int i = 1; i < n; i++){
		ll tt = k;
		ll xx = 0;
		for(int j = i-1; j >= 0; j--){
			if(arr[j] <= arr[i]){
				if((arr[i]-arr[j]) >= 0) {
					tt -= (arr[i]-arr[j]);
					if(tt >= 0) xx++;
				}
			}
		}
		if((xx+1) > ans){
			ans = (xx+1);
			ind = arr[i];
		}
	}
	if(ans > 1) cout<<ans<<" "<<ind<<"\n";
	else cout<<1<<" "<<arr[0]<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,k; cin>>n>>k;
	ll arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	//for(auto cc : arr) cout<<cc<<" "; cout<<"\n";
	int pre[n+1]; pre[0] = 0; for(int i = 1; i <=  n; i++) pre[i] = pre[i-1]+arr[i-1];
	//for(auto cc : pre) cout<<cc<<" "; cout<<"\n";
	ll ans = 0;  ll ind = -1;
	for(int i = 1; i < n; i++){
		int l = 0;
		int r = i;
		int good = 0;
		while(l <= r){
			int mid = l + (r-l)/2;
			if((arr[i]*((i-mid)))- (pre[i]-pre[mid]) <= k){
				//cout<<"arr[i] is "<<arr[i]<<" "<<"(i-mid) is "<<(i-mid)<<" "<<"pre[i+1] is "<<pre[i+1]<<" "<<"pre[mid] is "<<pre[mid]<<"\n";
				good = (i-mid)+1;
				r = mid-1;
			}
			else l = mid+1;
			//cout<<mid<<" ";
		}
		if(good > ans){
			ans = good;
			ind = arr[i];
		}
		//cout<<"\n";
	}
	if(ans > 1) cout<<ans<<" "<<ind<<"\n";
	else cout<<1<<" "<<arr[0]<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n,k;
	cin>>n>>k;
	long long arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	long long c;
	long long  best = 0;
	long long  ind;
	for(int i = 0; i <  n; i++){
		c = k;
		long long  ans = 0;
		for(int j = i-1; j >= 0; j--){
			if(c >= (arr[i]-arr[j])){
				c -= arr[i]-arr[j];
				ans++;
			}
			else break;
		}
		if(ans > best){
			ind = arr[i];
			best = ans;
		}
	}
	cout<<best+1<<" "<<ind<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,k; cin>>n>>k;
	ll arr[n]; for(int i = 0; i < n; i++) cin>>arr[i];
	sort(arr,arr+n);
	//for(auto cc : arr) cout<<cc<<" "; cout<<"\n";
	ll pre[n+1]; pre[0] = 0; for(int i = 1; i <=  n; i++) pre[i] = pre[i-1]+arr[i-1];
	//for(auto cc : pre) cout<<cc<<" "; cout<<"\n";
	ll ans = 0;  ll ind = -1;
	for(int i = 1; i < n; i++){
		ll l = 0;
		ll r = i;
		ll good = 0;
		while(l <= r){
			ll mid = l + (r-l)/2;
			if((arr[i]*((i-mid)))- (pre[i]-pre[mid]) <= k){
				//cout<<"arr[i] is "<<arr[i]<<" "<<"(i-mid) is "<<(i-mid)<<" "<<"pre[i+1] is "<<pre[i+1]<<" "<<"pre[mid] is "<<pre[mid]<<"\n";
				good = (i-mid)+1;
				r = mid-1;
			}
			else l = mid+1;
			//cout<<mid<<" ";
		}
		if(good > ans){
			ans = good;
			ind = arr[i];
		}
		//cout<<"\n";
	}
	if(ans > 1) cout<<ans<<" "<<ind<<"\n";
	else cout<<1<<" "<<arr[0]<<"\n";
}


#include <bits/stdc++.h>
using namespace std;

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;
ll tot, n, k, a[200001], cnt[200001], ans, idx;
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    //cout << cnt[0] << " ";
    for(int i=1; i<n; i++)
    {
        tot = tot+(a[i]-a[i-1])*i;
        cnt[i] = tot;
        //cout << tot << " ";
    }
    //cout << endl;
    for(int i=0; i<n; i++)
    {
        ll s = 0, e = i, m;
        while(s < e)
        {
            m = s+(e-s)/2;
            int x = cnt[i]-cnt[m]-(a[i]-a[m])*m;
            if(x <= k)
                e = m;
            else if(x > k)
                s = m+1;

        }
        //cout << e << endl;
        if(i-e+1 > ans)
            ans = i-e+1, idx = i;
    }
    cout << ans << " " << a[idx] << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;
int tot, n, k, a[200001], cnt[200001], ans, idx;
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    cout << cnt[0] << " ";
    for(int i=1; i<n; i++)
    {
        tot = tot+(a[i]-a[i-1])*i;
        cnt[i] = tot;
        cout << tot << " ";
    }
    cout << endl;
    for(int i=0; i<n; i++)
    {
        int s = 0, e = i, m;
        while(s < e)
        {
            m = s+(e-s)/2;
            int x = cnt[i]-cnt[m]-(a[i]-a[m])*m;
            if(x <= k)
                e = m;
            else if(x > k)
                s = m+1;

        }
        cout << e << endl;
        if(i-e+1 > ans)
            ans = i-e+1, idx = i;
    }
    cout << ans << " " << a[idx] << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;
ll tot, n, k, a[200001], cnt[200001], ans, idx;
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    //cout << cnt[0] << " ";
    for(int i=1; i<n; i++)
    {
        tot = tot+(a[i]-a[i-1])*i;
        cnt[i] = tot;
        //cout << tot << " ";
    }
    //cout << endl;
    for(int i=0; i<n; i++)
    {
        ll s = 0, e = i, m;
        while(s < e)
        {
            m = s+(e-s)/2;
            ll x = cnt[i]-cnt[m]-(a[i]-a[m])*m;
            if(x <= k)
                e = m;
            else if(x > k)
                s = m+1;

        }
        //cout << e << endl;
        if(i-e+1 > ans)
            ans = i-e+1, idx = i;
    }
    cout << ans << " " << a[idx] << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;
int tot, n, k, a[200001], cnt[200001], ans, idx;
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    //cout << cnt[0] << " ";
    for(int i=1; i<n; i++)
    {
        tot = tot+(a[i]-a[i-1])*i;
        cnt[i] = tot;
        //cout << tot << " ";
    }
    //cout << endl;
    for(int i=0; i<n; i++)
    {
        int s = 0, e = i, m;
        while(s <= e)
        {
            m = (s+e)/2;
            int x = cnt[i]-cnt[m]-(a[i]-a[m])*m;
            if(x <= k)
            {
                if(i-m+1 > ans)
                    ans = i-m+1, idx = i;
                e = m-1;
            }
            else if(x > k)
                s = m+1;

        }
        //cout << e << endl;
    }
    cout << ans << " " << a[idx] << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;
int tot, n, k, a[200001], cnt[200001], ans, idx;
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    cout << cnt[0] << " ";
    for(int i=1; i<n; i++)
    {
        tot = tot+(a[i]-a[i-1])*i;
        cnt[i] = tot;
        cout << tot << " ";
    }
    cout << endl;
    for(int i=0; i<n; i++)
    {
        int s = 0, e = i, m;
        while(s < e)
        {
            m = s+(e-s)/2;
            int x = cnt[i]-cnt[m]-(a[i]-a[m])*m;
            if(x <= k)
                e = m;
            else if(x > k)
                s = m+1;

        }
        //cout << e << endl;
        if(i-e+1 > ans)
            ans = i-e+1, idx = i;
    }
    cout << ans << " " << a[idx] << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;
int tot, n, k, a[200001], cnt[200001], ans, idx;
int main()
{
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    //cout << cnt[0] << " ";
    for(int i=1; i<n; i++)
    {
        tot = tot+(a[i]-a[i-1])*i;
        cnt[i] = tot;
        //cout << tot << " ";
    }
    //cout << endl;
    for(int i=0; i<n; i++)
    {
        int s = 0, e = i, m;
        while(s < e)
        {
            m = s+(e-s)/2;
            int x = cnt[i]-cnt[m]-(a[i]-a[m])*m;
            if(x <= k)
                e = m;
            else if(x > k)
                s = m+1;

        }
        //cout << e << endl;
        if(i-e+1 > ans)
            ans = i-e+1, idx = i;
    }
    cout << ans << " " << a[idx] << endl;
}


/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 720720
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

int n;
ll k;
vector<ll> a, pre_sum;

void solve() {
    scanf("%d %lld", &n, &k);
    a.resize(n + 1);
    pre_sum.resize(n + 1);
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    sort(a.begin() + 1, a.end());
    pre_sum[0] = 0;
    for(int i = 1; i <= n; i++) pre_sum[i] = pre_sum[i - 1] + a[i];
    int cnt = 0, val;
    for(int i = 1; i <= n; i++) {
        int low = 1, hi = i, mid, ret;
        while(hi >= low) {
            mid = (low + hi) / 2;
            ll m = pre_sum[i] - pre_sum[i - mid];
            if(a[i] * mid - m <= k) {
                ret = mid;
                low = mid + 1;
            }
            else hi = mid - 1;
        }
        if(ret > cnt) {
            cnt = ret;
            val = (int)a[i];
        }
    }
    printf("%d %d\n", cnt, val);
}

int main() {
    solve();
    return 0;
}


/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 720720
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

int n;
ll k;
vector<ll> a, pre_sum;

void solve() {
    scanf("%d %lld", &n, &k);
    a.resize(n + 1);
    pre_sum.resize(n + 1);
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    sort(all(a));
    pre_sum[0] = 0;
    for(int i = 1; i <= n; i++) pre_sum[i] = pre_sum[i - 1] + a[i];
    int cnt = 0, val;
    for(int i = 1; i <= n; i++) {
        int low = 1, hi = i, mid, ret;
        while(hi >= low) {
            mid = (low + hi) / 2;
            ll m = pre_sum[i] - pre_sum[i - mid];
            if(a[i] * mid - m <= k) {
                ret = mid;
                low = mid + 1;
            }
            else hi = mid - 1;
        }
        if(ret > cnt) {
            cnt = ret;
            val = (int)a[i];
        }
    }
    printf("%d %d\n", cnt, val);
}

int main() {
    solve();
    return 0;
}


/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 720720
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

int n;
ll k;
vector<ll> a, pre_sum;

void solve() {
    scanf("%d %lld", &n, &k);
    a.resize(n + 1);
    pre_sum.resize(n + 1);
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    //sort(all(a));
    sort(a.begin() + 1, a.end() + 1);
    pre_sum[0] = 0;
    for(int i = 1; i <= n; i++) pre_sum[i] = pre_sum[i - 1] + a[i];
    int cnt = 0, val;
    for(int i = 1; i <= n; i++) {
        int low = 1, hi = i, mid, ret;
        while(hi >= low) {
            mid = (low + hi) / 2;
            ll m = pre_sum[i] - pre_sum[i - mid];
            if(a[i] * mid - m <= k) {
                ret = mid;
                low = mid + 1;
            }
            else hi = mid - 1;
        }
        if(ret > cnt) {
            cnt = ret;
            val = (int)a[i];
        }
    }
    printf("%d %d\n", cnt, val);
}

int main() {
    solve();
    return 0;
}


/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 720720
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

int n;
ll k;
vector<ll> pre_sum;

void solve() {
    scanf("%d %lld", &n, &k);
    ll a[n + 1];
    pre_sum.resize(n + 1);
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    sort(a + 1, a + n + 1);
    pre_sum[0] = 0;
    for(int i = 1; i <= n; i++) pre_sum[i] = pre_sum[i - 1] + a[i];
    int cnt = 0, val;
    for(int i = 1; i <= n; i++) {
        int low = 1, hi = i, mid, ret;
        while(hi >= low) {
            mid = (low + hi) / 2;
            ll m = pre_sum[i] - pre_sum[i - mid];
            if(a[i] * mid - m <= k) {
                ret = mid;
                low = mid + 1;
            }
            else hi = mid - 1;
        }
        if(ret > cnt) {
            cnt = ret;
            val = (int)a[i];
        }
    }
    printf("%d %d\n", cnt, val);
}

int main() {
    solve();
    return 0;
}


/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 720720
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

int n;
ll k;
vector<ll> a, pre_sum;

void solve() {
    scanf("%d %lld", &n, &k);
    a.resize(n + 1);
    pre_sum.resize(n + 1);
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    sort(a.begin(), a.end());
    pre_sum[0] = 0;
    for(int i = 1; i <= n; i++) pre_sum[i] = pre_sum[i - 1] + a[i];
    int cnt = 0, val;
    for(int i = 1; i <= n; i++) {
        int low = 1, hi = i, mid, ret;
        while(hi >= low) {
            mid = (low + hi) / 2;
            ll m = pre_sum[i] - pre_sum[i - mid];
            if(a[i] * mid - m <= k) {
                ret = mid;
                low = mid + 1;
            }
            else hi = mid - 1;
        }
        if(ret > cnt) {
            cnt = ret;
            val = (int)a[i];
        }
    }
    printf("%d %d\n", cnt, val);
}

int main() {
    solve();
    return 0;
}