Molly And Flame
Tag(s):

## Easy

Problem
Editorial
Analytics

Molly is in love with Sherlock .She wants to decide the nature of relationship between her and Sherlock using the game of FLAME.

FLAME stands for:
{"Friendship","Love","Affection","Marriage","Enemies"}

The rules of FLAME are:

1) The names of two people are taken.

2) Then the common letters are deleted from both the names.

3) Then x_rem is calculated which is the number of leftover letters in both the names.

4) Count through the letters of "FLAME" x_rem times. After you have counted the 5 letters of "FLAME," you can continue counting from 6 to 10 starting again at "F" and ending at "E," if needed. If you have more than 10 leftover letters, repeat the process a third time, starting with "F."

5) The letter at which you stop decides the nature of relationship.

Example:

1)consider the strings sherlock and molly.

2)After striking off the common letters : sherck my

3) x_rem = len(sherck) + len(my) = 8

4) counting through the letters of FLAME.

FLAME
12345
678

5) The count stops at A . Hence the result is Affection.

However , Molly is not happy with the result of the game(Affection) and she manipulates the string FLAME TO FALME to change the result of the game(Love).

Given two names perform minimum number of swaps on the string "FLAME" and print the new string so that nature of relationship is always Love.

Input Format:
First line containing number of testcases t. Next t lines contain two space separated names in lowercase.
Output Format:
Print the new string in a new line for each testcase.

Constraints:

• $1 \le T \le 100$
• $1 \le length of name \le 100000$

SAMPLE INPUT
2
sherlock molly
watson mary
SAMPLE OUTPUT
FALME
FALME
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

221B Baker Street: Code for Watson

OTHER PROBLEMS OF THIS CHALLENGE
• Data Structures > Advanced Data Structures
• Math > Game Theory
• Data Structures > Advanced Data Structures
• Algorithms > Graphs
• Algorithms > Graphs