// Arup Guha
// 7/17/2025
// Solution to UCF 1995 HS Contest Problem: Vhat's fur Dinner?

import java.util.*;

public class chef {
	
	// Hope I typed all of this correctly...UGH!
	final public static String[] OLDS = {"and", "And", "Then", "then", "the", "The",
		"Yes", "yes", "Which", "which", "x.", "x ", "w ", "w", "W", "d.", "d ", "p.",
		"p ", "v", "e ", "e.", "ir", "or", "ou", "ue", "Th", "th", "ick" };
		
	final public static String[] NEWS = {"und", "Und", "Den", "den", "der", "Der",
		"Ya", "ya", "Vich", "vich", "xy.", "xy ", "v ", "v", "V", "dy.", "dy ", "py.",
		"py ", "f", "ey ", "ey.", "ur", "ur", "oo", "oo", "D", "d", "ook"};
	
	public static void main(String[] args) {
		
		
		// Glad we don't have these problems any more.
		Scanner stdin = new Scanner(System.in);
		int nC = Integer.parseInt(stdin.nextLine());

		// Process lines.
		for (int loop=0; loop<nC; loop++) {
		
			// Read the line.
			String line = stdin.nextLine();
			
			// They say go left to right. 
			// The increment is weird so I will do it manually in the loop.
			for (int i=0; i<line.length();) {
				
				boolean replace = false;
				
				// Split sides.
				String left = line.substring(0, i);
				String right = line.substring(i);
				
				// Find the first rule that matches here.
				for (int j=0; j<OLDS.length; j++) {
					if (right.startsWith(OLDS[j])) {
				
						// We are making a replacement.
						replace = true;
							
						// Make the replacement and reform the string.
						right = right.replaceFirst(OLDS[j], NEWS[j]);
						line = left + right;
						
						// We can't touch the new replacement so update i as follows.
						i = left.length() + NEWS[j].length();
						break;
					}
				}
				
				// We only increment by 1 if no replacement was made.
				if (!replace) i++;
			}
			
			// Ta da!
			System.out.println(line);
		}
	}
}