In the game of "Spindie", players take turns spinning a spinner and rolling a die.

On each turn, they spin the spinner three times and roll the die between each pair of spins (i.e. the sequence on a single turn is: `Spin`

, `Roll`

, `Spin`

, `Roll`

, `Spin`

). Each spin of the spinner lands on some integer and each roll of the die results in an integer from to . The first spinner number is the base score. Then if a die roll is through , the player adds the next spinner number to their score. If they roll a , the next number is used to multiply their score. The winner is the player with the highest score after a set number of rounds.

Here are some example turns of Spindie:

Spin | Roll | Spin | Roll | Spin | Score |
---|---|---|---|---|---|

The input will contain test cases.

The first line of each test case will consist of an integer representing the number of integers on the spinner, where .

The next line contains the integers on the spinner, through , separated by spaces, where .

The next line will contain five target integers through separated by spaces, where .

For each test case, your program should output a single line consisting of letters. Each letter should represent one of the five targets (in order). If the target represents a possible score in a single round of Spindie, then output a `T`

. If it is not possible, output an `F`

.

Note that the sample data below contains only test cases, but the test data will contain .

#### Sample Input

```
5
23 74 7 64 47
128605 205 2162 2709 71346
3
26 5 11
407 962 455 21 902
4
23 75 89 24
933 484 13248 102 44640
9
23 61 77 83 12 92 1 7 65
72900 144 5704 145 6370
7
87 20 94 99 14 26 87
241956 177 749331 221 4066
```

#### Sample Output

```
FFTFF
TTFTF
FFTFF
FTTTF
TFTFF
```

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org

## Comments

Can someone help me out a bit with a hint... I tried to aproach this problem in 3 ways: 1 - calculating all possible outcomes then check each target if is in possible outcomes 2 - calculating all possible outcomes but save only those who are between min/max of target then check each target if is in possible outcomes 3 - check each target if could be a possible solution by doing it in reverse and etc...

All aproaches gives me the correct output for all the samples above... but if I submit for a data set of 10 I get TDL for all of them.

I know that I must optimize my code to be more efficient and I don't see why.

Is there a math trick that I fail to see here ?!