Problem2241--Shampoo

2241: Shampoo

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100100 points

Problem Statement

Three people live in Takahashi's house: Takahashi, his father, and his mother. All of them wash their hair in the bathroom each night.
His father, his mother, and Takahashi take a bath in this order and use AABB, and CC milliliters of shampoo, respectively.
This morning, the bottle contained VV milliliters of shampoo. Without refilling, who will be the first to run short of shampoo to wash their hair?

Constraints

  • 1 \leq V,A,B,C \leq 10^51V,A,B,C105
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:
VVAABBCC

Output

If the first person to run short of shampoo to wash their hair is Takahashi's father, print F; if it is Takahashi's mother, print M; if it is Takahashi, print T.

Sample Input Copy

25 10 11 12

Sample Output Copy

T

HINT

Now, they have 2525 milliliters of shampoo.

  • First, Takahashi's father uses 1010 milliliters, leaving 1515.
  • Next, Takahashi's mother uses 1111 milliliters, leaving 44.
  • Finally, Takahashi tries to use 1212 milliliters and runs short of shampoo since only 44 is remaining.

Source/Category