import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m = "";
int cases=Integer.parseInt(br.readLine());
for(int z=0;z<cases;z++) {
m = br.readLine();
StringBuilder temp=new StringBuilder("");
StringBuilder[] str=new StringBuilder[4];
for(int i=0;i<str.length;i++){
str[i]=new StringBuilder("");
}
int index=-1;
boolean flag=false;
for(int i=0;i<m.length();i++){
if((m.charAt(i)>='a'&&m.charAt(i)<='z')||(m.charAt(i)==' ')){
temp.append(m.charAt(i));
if(flag && index <4)
str[index].append(m.charAt(i));
}
if(m.charAt(i)=='>'||m.charAt(i)=='<'){
flag=true;
index++;
}
}
sb.append(temp).append("\n");
m=br.readLine();
String[] line2=m.split("\\.\\.\\.");
if(line2.length>1)
sb.append(line2[0]).append(str[2]).append(str[1]).append(str[0]).append(str[3]).append(line2[1]).append("\n");
else if(line2.length==0)
sb.append(str[2]).append(str[1]).append(str[0]).append(str[3]).append("\n");
else
sb.append(line2[0]).append(str[2]).append(str[1]).append(str[0]).append(str[3]).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment