// Arup Guha
// 7/10/2014
// Solution to SI@UCF Week #1 Algorithms Contest Problem: Tots Adorbs

import java.util.*;

public class tots {

    public static void main(String[] args) {

        Scanner stdin = new Scanner(System.in);
        int numCases = stdin.nextInt();

        // Go through each case.
        for (int loop=0; loop<numCases; loop++) {

            // Read in the phrase.
            String s = stdin.next();
            String t = stdin.next();
            int sLen = s.length();
            int tLen = t.length();

            // This is tots what we want ;)
            System.out.println(s.substring(0, sLen-4)+"s "+t.substring(0, tLen-4)+t.charAt(tLen-3)+"s");
        }
    }
}
