// Arup Guha
// 3/26/2021
// Solution to 2021 Code Jam Qualifying Question: Revsort Engineering

import java.util.*;

public class Solution {

	public static void main(String[] args) {

		// Get # of cases.
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=1; loop<=nC; loop++) {
		
			// Get input.
			int n = stdin.nextInt();
			int c = stdin.nextInt();
			
			// Out of range; can't do it.
			if (c < n-1 || c >= n*(n+1)/2)
				System.out.println("Case #"+loop+": IMPOSSIBLE");
				
			// We can always do it, if it's in range.
			else {
			
				// Create a non-increasing sequence of values
				// that adds to our cost.
				int[] skips = new int[n];
				int left = c;
				for (int i=0; i<n-1; i++) {
					
					// Only allowed value.
					if (left == n-1-i)
						skips[i] = 1;
					
					// Max allowed at this level.
					else if (left - (n-i) >= n-2-i) 
						skips[i] = n-i;
					
					// Most we can do before all 1s.
					else
						skips[i] = left - (n-2-i);
						
					// Subtract out from cost.
					left -= skips[i];
				}
				
				// Just for how my code works.
				skips[n-1] = 1;
				
				// fill is when we place values.
				// fill[i] will store the -"real index"
				// so I know where to put stuff in my answer.
				int[] fill = new int[n];
				for (int i=0; i<n; i++) fill[i] = -i;
				
				// Storing the answer here.
				int[] res = new int[n];
				
				// Go through the numbers in order.
				for (int i=0; i<n; i++) {
					
					// Where I must place value i+1.
					int look = i+skips[i]-1;
					
					// Fill tells me where this value goes.
					res[-fill[look]] = i+1;
					
					// Update fill...
					fill[look] = i+1;
					
					// Reverse the relevant part of the array.
					reverse(fill, i, look);
				}
				
				// Ta da!
				System.out.print("Case #"+loop+":");
				for (int i=0; i<n; i++)
					System.out.print(" "+res[i]);
				System.out.println();
			}
		}
	}
	
	public static void reverse(int[] arr, int s, int e) {
		for (int i=s,j=e; i<j; i++,j--) {
			int tmp = arr[i];
			arr[i] = arr[j];
			arr[j] = tmp;
		}
	}
}