import java.util.Scanner;
public class P2564 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
sc.nextLine();//过度
while(t-->0){
String str=sc.nextLine();
String result="";
if (str.charAt(0)!=' ') {
result += str.charAt(0);
}
for(int i=0;i<str.length()-1;i++){
if(str.charAt(i)==' '&&str.charAt(i+1)!=' '){//注意空格
result+=str.charAt(i+1);
}
}
result=result.toUpperCase();
System.out.println(result);
}
}
}