publicstaticvoidflipWord()throws Exception { BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int t = parseInt(in.readLine());
while (0 < t--) { Stack<Character> stack = new Stack<>(); String word = in.readLine() + "\n"; for (int i = 0; i < word.length(); i++) { char ch = word.charAt(i); if (ch != ' ' && ch != '\n') { stack.push(ch); continue; } while(!stack.isEmpty()) { out.write(stack.pop()); } out.write(ch); } out.flush(); } out.close();; in.close();; }