package test2;
import java.util.Scanner;
public class StringDemo {
public static void main(String [] a){
Scanner in=new Scanner(System.in);
while(true){
String s=in.nextLine();
if(s.equalsIgnoreCase("quit")){
System.exit(0);
}
String[] ss=s.split("\s+");
StringBuffer sb=new StringBuffer();
for (int i=ss.length-1;i>=0;i--){
sb.append(ss[i]+" ");
}
System.out.println(sb);
}
}
}