BEMINE - Bermuda Love Triangle

no tags 

Bermuda triangle is also known as Devil's triangle. Many people disappeared their with their ships/planes. Love triange is a triangle where when someone gets into it's uncertainity he disappears from himself. So bermuda love triangle is a triangle where there is uncertainity from each angle. Here is a story of Barmuda love triangle, where 3 vertex consists of 2 girls and a boy. Both of the girls love the boy and they are best friends also. The boy feels same for the both girls. So, its a Uncertainity-Uncertainity-Uncertainity triangle. As this can't go like this, they all want a solution. As students of CS department they found a solution.

The boy will be holding two infinite series in two hands, the first girl will pick a series, the 2nd girl gets the rest. Then the 2nd girl will tell a number x where both sequence will end. Now , whose result of the series will have a larger prime divisor will get the boy. If the result for both series is equal then they will all be friends. 

Given the serieses, first girl's choice, second girl's choosen  x, find who will win the boy, or they will be friends. 

Series 1= 1+2+3+4+5+6+..................+x

Series 2= 0!+1*1!+2*2!+3*3!+4*4!+...............+x*x!

Use faster I/O


The first line contains an integer 0<t<10000 , number of testcases.

Next t lines contain 2 integer 1<=s<=2 and 2<=x<=108 ,Here s is the choice of the first girl, and x is the end of the series.


For each testcase print "First" if the first girl wins the boy, print "Second" if the second one wins, "Friends" else.


1 2
2 50
2 36
1 20


hide comments
Vipul Srivastava: 2018-11-29 10:19:17

Thanks for the reply nadstratosfer. It clarified some serious misunderstanding I had regarding the problem.

nadstratosfer: 2018-11-29 04:33:56

s1[36] = 666 = 2 * 3^2 * 37
s2[36] = 13763753091226345046315979581580902400000000 = 2^34 * 3^17 * 5^8 * 7^5 * 11^3 * 13^2 * 17^2 * 19 * 23 * 29 * 31 * 37

Vipul Srivastava: 2018-11-27 18:33:32

How are the largest prime divisors in case of 36 same?

Added by:Safayet
Time limit:1s-2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)