import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class D{
private static int tLength=0;
public static void main(String []args)throws IOException{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb=new StringBuffer();
int n= Integer.parseInt(in.readLine());
for(int i=0;i<n;i++){
String temp=in.readLine();
String []data=temp.split(" ");
tLength=data.length;
String operation="";
for(int j=0;j<tLength;j++){
if(data[j].equals("/")){
data[j-1]=String.valueOf(Integer.parseInt(data[j-1])/Integer.parseInt(data[j+1]));
data=reduceElement(data,j);
operation+="/ ";
j--;
}
else if(data[j].equals("*")){
data[j-1]=String.valueOf(Integer.parseInt(data[j-1])*Integer.parseInt(data[j+1]));
data=reduceElement(data,j);
operation+="* ";
j--;
}
}
for(int j=0;j<tLength;j++){
if(data[j].equals("+")){
data[j-1]=String.valueOf(Integer.parseInt(data[j-1])+Integer.parseInt(data[j+1]));
data=reduceElement(data,j);
operation+="+ ";
j--;
}
else if(data[j].equals("-")){
data[j-1]=String.valueOf(Integer.parseInt(data[j-1])-Integer.parseInt(data[j+1]));
data=reduceElement(data,j);
operation+="- ";
j--;
}
}
sb.append("Case #"+(i+1)+": "+operation+data[0]+"\n");
}
System.out.println(sb.toString());
}
public static String []reduceElement(String []data,int index){
tLength-=2;
for(int i=index;i<tLength;i++){
data[i]=data[i+2];
}
return data;
}
}