Chef is looking to buy a TV and has shortlisted two models. The first one costs π΄A rupees, while the second one costs π΅B rupees.
Since there is a huge sale coming up on Chefzon, Chef can get a flat discount of πΆC rupees on the first TV, and a flat discount of π·D rupees on the second one.
Help Chef determine which of the two TVs would be cheaper to buy during the sale.
Input Format
- The first line contains a single integer πT β the number of test cases. Then the test cases follow.
- The first and only line of each test case contains four space-separated integers π΄A, π΅B, πΆC and π·D β the marked price (in rupees) of the first TV, the marked price (in rupees) of the second TV, the flat discount (in rupees) of the first TV, and the flat discount (in rupees) of the second TV.
Output Format
For each test case, print a single line containing the string First
if the first TV is cheaper to buy with discount, or Second
if the second TV is cheaper to buy with discount. If both of them cost the same after discount, print Any
.
You may print each character of the string in uppercase or lowercase (for example, the strings first
, First
, fIRSt
, and FIRST
will all be treated as identical).
Constraints
- 1β€πβ€50001β€Tβ€5000
- 1β€π΄,π΅β€1001β€A,Bβ€100
- 0β€πΆβ€π΄0β€Cβ€A
- 0β€π·β€π΅0β€Dβ€B
Sample 1
Inputcopy | Outputcopy |
---|---|
3 85 75 35 20 100 99 0 0 30 40 0 10 | First Second Any |
Test case 11: The cost of the first TV after discount is 85β35=5085β35=50, while the cost of the second TV after discount is 75β20=5575β20=55. Thus the first TV is cheaper to buy than the second.
Test case 22: The cost of the first TV after discount is 100β0=100100β0=100, while the cost of the second TV after discount is 99β0=9999β0=99. Thus the second TV is cheaper to buy than the first.
Test case 33: The cost of the first TV after discount is 30β0=3030β0=30, while the cost of the second TV after discount is 40β10=3040β10=30. Since they are equal, Chef can buy any of them.
Solutions:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int T = scanner.nextInt();
for (int i = 0; i < T; i++) {
int A = scanner.nextInt();
int B = scanner.nextInt();
int C = scanner.nextInt();
int D = scanner.nextInt();
int costFirstTV = A - C;
int costSecondTV = B - D;
if (costFirstTV < costSecondTV) {
System.out.println("First");
} else if (costFirstTV > costSecondTV) {
System.out.println("Second");
} else {
System.out.println("Any");
}
}
scanner.close();
}
}