Three friends got bored with their old card games, so decided to invent a new game. Let the name of three friends be player 1, player 2 and player 3.
In this new game, there are 26 different types of cards with infinite supply of every card. Each friend picks random number of cards in random order. They want to find out how close first two friends(player 1 and player 2) are with respect to the third friend(player 3). For this, they need to find the longest common subsequence of cards, that appears in the cards picked by first two friends(player 1 and player 2), without disturbing the order of given cards. Let us call this series as deck. But this deck should not be the string formed by the cards picked by third friend(player 3).
Input:
First line consists of T test cases.
Next Three lines of input consisting of three string of player 1, 2 and 3 respectively. (Only uppercase letters).
Output:
Print the length of the final string(deck) formed, if not possible print 0.
Constraints:
1<=T<=10
1<=|String|<=100
Example:
Input:
1
ABC
ACB
AB
Output:
2
Explaination :
All the possible subsequence are A, B, C, AC , AB.
Therefore, AC whose length is 2 is different from the series of Player 3.
Ans : Length is 2.
11620078 | 164 |
RohitBattu | 127 |
Maninder07 | 126 |
blackshadows | 120 |
Rags Bhasin | 110 |
blackshadows | 880 |
xmyqsh | 565 |
mb1973 | 439 |
aman19 | 402 |
shubhamjain237 | 376 |
akhayrutdinov | 5014 |
Ibrahim Nash | 4899 |
Quandray | 4338 |
sanjay05 | 3668 |
blackshadows | 3384 |