/**
 * @(#)method.java
 *
 *
 * @author : danDeblasio
 * @version 1.00 2008/7/10
 */

import java.util.*;
import java.io.*;

public class method {
        
    public static void main(String[] args) throws FileNotFoundException {
    	
    	// Open file.
        Scanner fin = new Scanner(new File("method.in"));
        
        // Get number of cases.
        int n = fin.nextInt();
        for(int i=0;i<n;i++){
        	
        	// Read in the two input strings for the case.
        	String s1 = fin.next();
        	String s2 = fin.next();
        	
        	// Change them to lower case.
        	s1 = s1.toLowerCase();
        	s2 = s2.toLowerCase();
        	
        	// Just replace the first character of the second string with its uppercase counterpart.
        	s2 = s2.replaceFirst(String.valueOf(s2.charAt(0)),String.valueOf(Character.toUpperCase(s2.charAt(0))));
        	
        	// Put the strings together.
        	String out = s1.concat(s2);
        	
        	// Output it.
        	System.out.println(out);
        }
        
        fin.close();
    }
}
