// Arup Guha
// 5/2/2014
// Solution to 2014 UCF High School Contest Problem: Journey to Batlantis!

import java.util.*;
import java.io.*;

public class batlantis {
	
	public static void main(String[] args) throws Exception {
		
		Scanner fin = new Scanner(new File("batlantis.in"));
		int numCases = fin.nextInt();
		
		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {
			String w1 = fin.next();
			String w2 = fin.next();
			System.out.println("Entry #"+loop+": "+solve(w1,w2));
		}
		fin.close();
	}
	
	// Returns the solution to the given problem. Finding the maximum length b such that
	// left = ab and right = bc, and returns abc.
	public static String solve(String left, String right) {
		
		int len1 = left.length();
		int len2 = right.length();
		int ans = Math.min(len1, len2);
		
		// Try each possible length of b from greatest to least.
		while (ans > 0) {
			
			// Found a match, get out!
			if (left.substring(len1-ans).equals(right.substring(0,ans)))
				break;
				
			// Try the next smaller value.
			ans--;
		}
		
		// The length of b is precisely what we cut off of the second string.
		return left + right.substring(ans);
	}
}