Given two strings, S and R, composed of only English alphabets (both upper and lower cases), find the alphabets that occur in both the strings. Print the common alphabets (if any) as output in ascending order of their ASCII values.
First line of input is an integer T, denoting the number of test cases. For each test case, first line of input is the string S and second line is the string R. Repetition is allowed in both the strings.
The only line of output for each test case is the list of alphabets that occur in both S and R. Upper and lower case alphabets are treated to be distinct from each other i.e. 'A' and 'a' will be regarded two different letters. The letters are printed on a new line in ascending order of ASCII values i.e. capital letters in common will be printed first in the output. If there are no common letters in S and R, print "nil" as output (without quotes).
1<=|S|,|R|<=100, denoting length of strings.
The letters common in the first test case are H and v. Hence output is, Hv.
In the second test case, there is nothing common. Hence output is nil.
In the third test case, Y,b,x are common. Hence output is, Ybx.
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.