You are given a message string S consisting of lowercase English letters and a noise word “ada”. All words that can be formed by adding “da” any number of times at the end of noise is also considered as a noise. For example, the words “adada”, “adadadadada”, ”adada” are noise but “dada”, ”ad”, ”aad” are not considered noise. You are given with the message signal S and you have to move all the noise present in the message signal to the end (in the same order as they occur in the message S) so that the filter can truncate the noises from the end.
The first line contains a positive integer T denoting the number of test cases. Each of the next T lines contains a message string S.
For each test case print on a new line the new signal formed after moving all the noise at the end.
1 <= T <= 10^5
1 <= length (string) <= 10^5
For the 1st case: ”adada” and “ada” are the noises. Noises are moved to the end in the same order as they appear in the string S. There is no noise in the 2nd signal. For the 3rd case: “ada” and “adada” are the noises.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.