swapnil-and-the-bubble-game

Swapnil is playing a game with his friend.This game is about the bubbles.There are many sticky bubbles 
kept in a container A.Near that container,there is another container B containing plenty of chocalates.
There are two rounds in the game.The first round is about picking maximum no. of bubbles from the
container A.In this round,each will get one chocalate from container B for each bubble.In the second 
round,Swapnil randomly picks some bubbles from the container A.As the bubbles are sticky they get 
glued to each other.Now he asks his friend to pick some bubbles.Here the game is that if those bubbles
are sticked same as that of Swapnil then Swapnil's Friend will get 10 chocalates from container B for 
each bubble.Otherwise friend has to either pick new bubble and stick it according to Swapnil or remove 
any bubble or change any bubble to make it exactly same as that of Swapnil each for a cost of 5 chocalates
to Swapnil from container B.Friend has to ensure that the chocalate's loss from container B will be minimum 
in this round.At the end of the game,the winner is having the max chocalates.Given the bubbles picked by 
Swapnil and his friend, find how many chocalates Swapnil and his friend will have at the end of game.
Input:-
First line contains t denoting no. of test cases.
First line of each test case contains  n1 and n2 denoting no. of bubbles picked by Swapnil and his friend in first round.
Next line contains n denoting no. of bubbles picked by Swapnil in second round.
Next line contains a string denoting bubbles picked by Swapnil in second round.
Next line contains m denoting no. of bubbles picked by Swapnil's Friend in second round.
Next line contains a string denoting bubbles picked by Swapnil's Friend in second round.
Output:-
For each test case output is as
First Line contains p as number of chocalates with Swapnil at the end of game.
Next Line contains q as number of chocalates with Swapnil's Friend at the end of game.
Next Line output as "Swapnil" or "Friend" who wins or "Tie".
Constraints:-

TestCases: 20pts
1 ≤ t ≤ 2000
1 ≤ n ≤ 100
1 ≤ m ≤ 100
1 ≤ n1 ≤ 10^4
1 ≤ n2 ≤ 10^4
TestCases: 30 pts
1 ≤ t ≤ 400
1 ≤ n ≤ 500
1 ≤ m ≤ 500
1 ≤ n1 ≤ 10^5
1 ≤ n2 ≤ 10^5
TestCases: 50 pts
1 ≤ t ≤ 100
1 ≤ n ≤ 1000
1 ≤ m ≤ 1000
1 ≤ n1 ≤ 10^6
1 ≤ n2 ≤ 10^6SAMPLE INPUT
1
15 10
5
abcde
4
abcd

SAMPLE OUTPUT
20
10
Swapnil

Explanation

In the first round, Swapnil picked 15 bubbles and his friend 10 bubbles.
In the second round,Swapnil has bubbles abcde but his friend has abcd
so friend will pick one bubble e and stick to those bubbles.He will give
5 chocalates to Swapnil from container B.At the end,Swapnil has 20 and
his friend has 10 chocalates so Swapnil wins the game.

Source: hackerearth | Difficulty: EASY


Solutions: