This is a simple game you must have played around with during your school days, calculating FLAMES of you and your crush! Given the names of two people, cancel out the common letters (repeated occurrence of a letter is treated separately, so 2A's in one name and one A in the other would cancel one A in each name), count the total number of remaining letters (n) and repeatedly cut the letter in the word FLAMES which hits at the nth number when we count from F in cyclic manner.

For example:
NAME 1: SHILPA
NAME 2: AAMIR
After cutting the common letters: 
NAME 1: SHILPA 
NAME 2: AAMIR
Total number of letters left=7
FLAMES, start counting from F : 1=F, 2=L, 3=A, 4=M, 5=E, 6=S,7=F...So cut F
FLAMES: repeat this process with remaining letters of FLAMES for number 7 (start count from the letter after 
the last letter cut) . In the end, one letter remains. Print the result corresponding to the last letter:
F=FRIENDS
L=LOVE
A=ADORE
M=MARRIAGE
E=ENEMIES
S=SISTER

-----Input-----
The no. of test cases (<100)
two names (may include spaces) for each test case.


-----Output-----
FLAMES result (Friends/Love/...etc) for each test case

-----Example-----
Input:
2
SHILPA
AAMIR
MATT
DENISE

Output:
ENEMIES
LOVE



By:
Chintan, Asad, Ashayam, Akanksha

Starter code:

Solutions:
import sys

def joseph(k, n=6):
	if k==0:
		k = 1
	x = 0
	for i in range(2,n+1):
		x = (x+k)%i
	return x

FLAMES = ['FRIENDS', 'LOVE', 'ADORE', 'MARRIAGE', 'ENEMIES', 'SISTER']

nCase = int(sys.stdin.readline())
for _ in range(nCase):
	a = ''.join(sys.stdin.readline().split())
	b = ''.join(sys.stdin.readline().split())
	n = 0
	for ch in set(a+b):
		n += abs(a.count(ch)-b.count(ch))
	print(FLAMES[joseph(n)])


import sys

def main():
    s = sys.stdin.readline
    t = int(s())
    for i in range(t):
        name = s().strip().lower()
        if ' ' in name:
            name = name.replace(' ', '')
        crush = s().strip().lower()
        if ' ' in crush:
            crush = crush.replace(' ', '')
        namecounter = {}
        crushcounter = {}
        for letter in name:
            if letter in namecounter:
                namecounter[letter] += 1
            else:
                namecounter[letter] = 1
    
        for letter in crush:
            if letter in crushcounter:
                crushcounter[letter] += 1
            else:
                crushcounter[letter] = 1
        counter = 0
        already = []
        for letter in name:
            if letter in crush:
                if letter not in already:
                    if namecounter[letter] == crushcounter[letter]:
                        already.append(letter)
                        continue
                    else:
                        counter += abs(namecounter[letter]-crushcounter[letter])
            else:
                counter += 1
            already.append(letter)
        for letter in crush:
            if letter not in already:
                counter += 1
        values = {1: 'FRIENDS', 2: 'LOVE', 3: 'ADORE', 4: 'MARRIAGE', 5: 'ENEMIES', 6: 'SISTER'}
        result = 0
        for i in range(1, 6+1):
                result = (result+counter)%i
        print(values[result+1])
        
def __starting_point():
    main()
__starting_point()

import sys

alpha='abcdefghijklmnopqrstuvwxyz'

for _ in range(int(sys.stdin.readline())):
    n1=sys.stdin.readline().strip().lower().replace(' ','')
    n2=sys.stdin.readline().strip().lower().replace(' ','')
    
    common=[0 for i in range(26)]
    
    for i in range(26):
        t1=n1.count(alpha[i])
        t2=n2.count(alpha[i])
        
        if t1==t2:
            common[i]=t1
        else:
            common[i]=min([t1,t2])
            
    for a in range(26):
        n1=n1.replace(alpha[a],'',common[a])
        n2=n2.replace(alpha[a],'',common[a])
        
    remain=len(n1)+len(n2)
    
    f=['f','l','a','m','e','s']
    index=0
    while len(f)>1 and remain!=0:
    
        l=remain%len(f)-1

        del f [l]
        
        if l!=0 and l!=-1:
            f=f[l:]+f[:l]
        
    if f[0]=='f'and remain!=0:
        print('FRIENDS')
    elif f[0]=='l':
        print('LOVE')
    elif f[0]=='a':
        print('ADORE')
    elif f[0]=='m':
        print('MARRIAGE')
    elif f[0]=='e':
        print('ENEMIES')
    elif f[0]=='s':
        print('SISTER')
    elif remain==0:
        print('SISTER')

WORDS = {"F":"FRIENDS", "L":"LOVE", "A":"ADORE", "M":"MARRIAGE", "E":"ENEMIES", "S":"SISTER"}
cases = int(input())
for case in range(cases):
    a = input().strip().lower()
    b = input().strip().lower()
    
    i = 0
    while i < len(a):
        k = b.find(a[i])
        
        if k != -1:
            a = a[:i]+a[i+1:]
            b = b[:k]+b[k+1:]
            i -= 1
        i += 1
        
    letters = len(a)+len(b)
    if letters == 0:
        print("SISTER")
        continue
    
    flames = "FLAMES"
    i = 0
    while len(flames) > 1:
        i = (i+letters-1) %len(flames)
        flames = flames[:i]+flames[i+1:]
    print(WORDS[flames])

import string

t=int(input().strip())
for _ in range(0,t):
	a=input().strip()
	b=input().strip()
	d={}
	e={}
	la=0
	lb=0
	for i in a:
		i=i.upper()
		if (i==' '):
			continue
		try:
			d[i]+=1
		except:
			d[i]=1
		la+=1
	for i in b:
		i=i.upper()
		if (i==' '):
			continue
		try:
			e[i]+=1
		except:
			e[i]=1
		lb+=1
	left=la+lb
##	print d
	for i in d:
		try:
			e[i]+=0
		except:
			continue
		if (d[i]<e[i]):
			left-=(2*d[i])
		else:
			left-=(2*e[i])
##        print left
	f = ['F','L','A','M','E','S']
	old=0
	for q in range(0,5):
		old=(((left%(6-q))+old)%(6-q)-1)%(6-q)
		f.pop(old)
	ans={'F':"FRIENDS", 'L':"LOVE", 'A':"ADORE", 'M':"MARRIAGE", 'E':"ENEMIES", 'S':"SISTER"}
	print(ans[f[0]])

#!/usr/bin/env python

WORDS = {'F':'FRIENDS',  'L':'LOVE',    'A':'ADORE',
         'M':'MARRIAGE', 'E':'ENEMIES', 'S':'SISTER'}

def process(N1, N2):
    N3 = ''
    for i in range(len(N1)):
        v = N2.find(N1[i])
        if v != -1: N2 = N2[:v] + N2[v+1:]
        else:       N3 = N3 + N1[i]
    N = len(N3 + N2)
    if N == 0: return 'SISTER' # ???
    ar = 'FLAMES'
    stp = 1
    for x in range(6, 1, -1):
        g = ((N%x)+stp)-1
        if g>x:
           g=g%x
        if g==0:
           g=len(ar)
        ar = ar[:g-1] + ar[g:]
        stp=g
    return WORDS[ar]

def main():
    T = int(input())
    for t in range(T):
        N1 = input()
        N2 = input()
        N1 = N1.upper().replace(' ', '') # ???
        N2 = N2.upper().replace(' ', '') # ???
        print(process(N1, N2))

main()