import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader() { reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String nextLine() { String s = null; try { s = reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } return s; } public String nextParagraph() { String line = null; String ans = ""; try { while ((line = reader.readLine()) != null) { ans += line; } } catch (IOException e) { throw new RuntimeException(e); } return ans; } } static int count=0; static int yes=0; static void lena_sort(int ar[],ArrayList result,int c,int len,int left,int right,int sum){ if(result.size()==len){ //System.out.println("Inside Function ::"+result.size()+" "+count+" "+sum); if(c<=sum){ yes=1; }else{ yes=0; } return; } else if(result.size()==len&&c!=count){ //System.out.println("Inside Function G::"+result.size()+" "+count); yes=0; return; } if(left>right){ //System.out.println("Inside Function No::"+result.size()+" "+count); return; } int pivot=ar[left+(right-left)/2]; int indx=(left+(right-left)/2); result.add(pivot); count+=(right-left); lena_sort(ar,result,c,len,left,indx-1,sum); lena_sort(ar,result,c,len,indx+1,right,sum); } public static void main(String[] args) throws IOException{ InputReader sc = new InputReader(); PrintWriter pw=new PrintWriter(System.out); int q = sc.nextInt(); for(int a = 1; a <= q; a++){ int len = sc.nextInt(); int c = sc.nextInt(); count=0; yes=0; int ar[]=new int[len],i,sum=0; ArrayList result=new ArrayList(); for(i=0;i