
Alphabet Difference
Problem Code: ALPDIFF
click Advertisement for answer
Submit
You are given two strings A and B containing small english alphabets ['a' - 'z']. You have to find the set of distinct characters that are present in string B but not in A. Print this set of characters sorted in increasing order in the form of a string.
If there are no such characters that are present in B but not in A, then print -1.
Note
You just need to print an alphabet once in the resultant string if its present in string B but not in string A.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
First line of each testcase contains string A.
Second line of each testcase contains string B.
Output
For each test case, output a single line containing answer.
Constraints
1 ≤ T ≤ 20
1 ≤ Length of string A , B ≤ 100000
Information to Score Partial Points
For 5% of the score, it is guaranteed that Length of strings are ≤ 26 and all alphabets in string B are distinct.
For 30% of the score, it is guaranteed that Length of strings are ≤ 500.
For rest 65% of the score, original constraints are applicable.
Example
Input:
2
codechef
certification
teacher
cheater
Output:
ainrt
-1
Explanation
Test case 1: String A is "codechef" and string B is "certification". {'a','i','n','r','t'} are the characters present in string B but not in A.
Test case 2: String A is "teacher" and string B is "cheater". Since all the alphabet in string B are also present in string A, hence answer is -1.
0 Comments