// Arup Guha
// 4/26/2021
// Solution to 2021 Code Jam Round 1B Problem B: Subtransmutation

import java.util.*;

public class Solution {
	
	public static int n;
	public static int a;
	public static int b;
	public static int[] need;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();

		// Process cases.
		for (int loop=1; loop<=nC; loop++) {
			
			// Get input.
			n = stdin.nextInt();
			a = stdin.nextInt();
			b = stdin.nextInt();
			need = new int[n+1];
			for (int i=1; i<=n; i++)
				need[i] = stdin.nextInt();
			
			// See the smallest value that works. If we get to a 1000 nothing will.
			int low = 1;
			boolean flag = false;
			while (true) {
				if (canDo(low)) break;
				low++;	
				if (low == 1000) { flag = true;break;}
				
			}
			
			// Ta da!
			if (!flag)
				System.out.println("Case #"+loop+": "+low);			
			else
				System.out.println("Case #"+loop+": IMPOSSIBLE");
		}
	}
	
	public static boolean canDo(int val) {
		
		// Initial conditions.
		int[] cur = new int[Math.max(21,val+1)];
		cur[val] = 1;
		
		// Do the rounds.
		for (int i=val; i>n; i--) {
			
			// Transmute!
			if (cur[i] > 0) {
				if (i-a>= 1) cur[i-a] += cur[i];
				if (i-b>= 1) cur[i-b] += cur[i];
				if (i-a>=1 && cur[i-a] >= 1000000000) cur[i-a] = 1000000000;
				if (i-b>=1 && cur[i-b] >= 1000000000) cur[i-b] = 1000000000;
			}
			
		}
		
		// Check all of these. If you have excess transmute.
		for (int i=n; i>=1; i--) {
			if (cur[i] < need[i]) return false;
			if (cur[i] > need[i]) {
				if (i-a>=1) cur[i-a] += (cur[i]-need[i]);
				if (i-b>=1) cur[i-b] += (cur[i]-need[i]);
				if (i-a>=1 && cur[i-a] >= 1000000000) cur[i-a] = 1000000000;
				if (i-b>=1 && cur[i-b] >= 1000000000) cur[i-b] = 1000000000;
			}
		}
		
		// Good if we get here.
		return true;
	}
}
