import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Bugs {
static ArrayList<String> tmp = new ArrayList<String>();
int x;
char c;
do {
if(line == null) {
break;
}
tmp.clear();
int lines
= Integer.
parseInt(st.
nextToken()); for(int i = 0; i < lines; i++) {
line = br.readLine();
x = 0;
for(int j = 0; j < line.length(); j++) {
c = line.charAt(j);
if (c== (word.charAt(0))) {
tmp.add(c+"");
x=1;
} else if (c== (word.charAt(x))) {
String tempString
= tmp.
get(tmp.
size()-1) + c
; tmp.set(tmp.size()-1, tempString);
x++;
if(x == word.length()) {
tmp.remove(tmp.size() -1);
if(tmp.size() > 0) {
x = tmp.get(tmp.size()-1).length();
} else {
x = 0;
}
}
} else {
x = 0;
}
System.
out.
print(line.
charAt(j
)); tmp.clear();
}
}
}
} while(true);
}
}