//Anamary Leal
//July 20, 2006
//Jar: Given how much you can carry, and how many jars you must attempt to empty out, print out how many remainderes are left.

// Edited by Arup Guha to fit the edited spec for the 2011 Week2 BHCSI contest.
import java.io.*;
import java.util.*;

public class jars
{
	
	public static void main(String [] args) throws IOException
	{
		//Declare the injput
		Scanner input = new Scanner(new File("jars.in"));
		
		int n = input.nextInt();
		
		for (int i=1; i<=n; i++) {
		
		
			//read in your storage devices' capacity
			int mycap = input.nextInt();
		
			double leftover = 0, tank = 0;
			int numjars = input.nextInt();
			int jar = 0;

			//go through all the jars
			while(jar < numjars)
			{
				tank = 0;
							
				//fill up one of your storage devices
				//tank will keep track of how much i've filled my storage device
				//if tank > mycap, then there is an overflow; coutn that overflow as leftovers
				while(tank < mycap && jar < numjars)
				{
					tank += input.nextDouble();
					jar++;
				}
					
			
				//if it did not overfill(tank - mycap) = negative number
				//don't count it as a remainder
				if((tank - mycap) > 0)
				{
					//a tank is overfilled, let its remainder be its leftover
					leftover += tank - mycap;
				}
				
			}
		
			//output it to the screen
			System.out.println("Case "+i+": The volume of the leftover chemical will be " + leftover + " cm^3.");	
		}
	}
	
}