Fork Copy package ngay4; import java.util.Scanner; public class bai1 { public static int exchange(String s) { if(s.equals("ZRO")) return 0; if(s.equals("ONE")) return 1; if(s.equals("TWO")) return 2; if(s.equals("THR")) return 3; if(s.equals("FOR")) return 4; if(s.equals("FIV")) return 5; if(s.equals("SIX")) return 6; if(s.equals("SVN")) return 7; if(s.equals("EGT")) return 8; return 9; } public static String exchangeS(int s) { switch (s) { case 0: return "ZRO"; case 1: return "ONE"; case 2: return "TWO"; case 3: return "THR"; case 4: return "FOR"; case 5: return "FIV"; case 6: return "SIX"; case 7: return "SVN"; case 8: return "EGT"; } return "NIN"; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = Integer.parseInt(sc.nextLine()); for(int tc = 1; tc <= t; tc++) { String line1 = sc.next(); String[] part1 = line1.split(" "); int n = Integer.parseInt(sc.next()); int a[] = new int[n]; for(int i = 0; i < n; i++) { a[i] = exchange(sc.next()); } for(int i = 0;i < n-1; i++) { for(int j = 0; j < n-1-i; j++) { if(a[j] > a[j+1]){ int tmp = a[j]; a[j] = a[j+1]; a[j+1] = tmp; } } } System.out.println(part1[0]); for(int i = 0; i < n; i++) { System.out.print(exchangeS(a[i]) + " "); } } } }