Problem: cf1705_f
Difficulty: hard
Categories: bit
Time limit: 2000 ms, memory limit: 256 MB

Mark is administering an online exam consisting of $n$ true-false questions. However, he has lost all answer keys. He needs a way to retrieve the answers before his client gets infuriated.

Fortunately, he has access to the grading system. Thus, for each query, you can input the answers to all $n$ questions, and the grading system will output how many of them are correct.

He doesn't have much time, so he can use the grading system at most $675$ times. Help Mark determine the answer keys.

Note that answer keys are fixed in advance and will not change depending on your queries.

Input

The first line of the input consists of an integer $n$ ($1\leq n\leq 1000$) — the number of questions.

Interaction

After reading $n$, you can start making queries to the grading system. For each query, print a line containing a string $s$ of length $n$ consisting of only letters 'T' and 'F'.

* $s_i = $'T' means that you answer the $i$-question true.
* $s_i = $'F' means that you answer the $i$-question false.

After a successful query, you should read an integer $k$ ($0\leq k\leq n$) — the number of correct answers. If you read $n$, then you found the answers, and your program should not make any more queries.

If your program reads $k = -1$ instead of the number of correct answers, it means that you either made an invalid query or exceeded the query limits. Exit immediately after receiving $-1$, and you will see Wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.

After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see documentation for other languages.

Examples

Input

```
3

1

3
```

Output

```
FTT

TTF
```

Input

```
4

0

3

4
```

Output

```
FTFF

TTTT

TFTT
```

Note

The empty lines in the example are just for you to better understand the interaction process. You're not required to print them.

In the first example, there are $3$ questions, and the answer to each question is 'true', 'true', and 'false', respectively.

* The first query, guessing the answers to be 'false', 'true', and 'true', respectively, guesses only one question — the $2$-nd question — correctly.
* Then, in the second query, the program correctly guesses the answer key. The interaction ends here.

In the second example, there are $4$ questions, and the answer to each question is 'true', 'false', 'true', and 'true', respectively.

* The first query guessed none of the questions correctly, resulting in the answer $0$.
* The second query guessed the $1$-st, $3$-rd, and $4$-th question correctly, resulting in the answer $3$.
* In the third query, the program correctly guesses the answer key. Then, the interaction ends.

Non-adaptive interactor (C++):
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;


static long long queries = 0;
static long long query_limit = 675;



static void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {
        
    }
}


static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}

int main(int argc, char** argv) {
    registerInteraction(argc, argv);
    atexit(log_metrics);

    
    
    int n = inf.readInt();
    string s = inf.readToken();

    
    if (s.length() != (size_t)n) {
        quitf(_fail, "Generator error: string length %d does not match n=%d", (int)s.length(), n);
    }

    
    query_limit = 675;

    
    cout << n << endl;

    
    while (true) {
        string token;
        
        if (!(cin >> token)) {
            finish(_wa, "Unexpected EOF (no answer found)");
        }

        string guess;
        bool is_final_answer = false;

        
        
        
        
        if (token == "!") {
            is_final_answer = true;
            if (!(cin >> guess)) {
                finish(_wa, "Expected string after '!'");
            }
        } else if (token == "?") {
            if (!(cin >> guess)) {
                finish(_wa, "Expected string after '?'");
            }
        } else {
            
            guess = token;
        }

        
        if (guess.length() != (size_t)n) {
            
            if (!is_final_answer) cout << -1 << endl;
            finish(_wa, format("Invalid string length: expected %d, got %d", n, (int)guess.length()));
        }

        
        bool valid_chars = true;
        for (char c : guess) {
            if (c != 'T' && c != 'F') {
                valid_chars = false;
                break;
            }
        }
        if (!valid_chars) {
            if (!is_final_answer) cout << -1 << endl;
            finish(_wa, "Invalid characters in guess (must be 'T' or 'F')");
        }

        
        int correct_count = 0;
        for (int i = 0; i < n; i++) {
            if (guess[i] == s[i]) {
                correct_count++;
            }
        }

        if (is_final_answer) {
            
            if (correct_count == n) {
                finish(_ok, "Correct answer provided via '!'");
            } else {
                finish(_wa, format("Wrong answer provided via '!': %d/%d matches", correct_count, n));
            }
        } else {
            
            
            if (queries >= query_limit) {
                cout << -1 << endl;
                finish(_wa, format("Query limit exceeded (%lld queries)", queries + 1));
            }

            queries++;
            cout << correct_count << endl;
            
            
            log_metrics();

            
            if (correct_count == n) {
                finish(_ok, format("Correct answer found via query in %lld queries", queries));
            }
        }
    }

    return 0;
}


Adaptive interactor (C++):
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;


static long long queries = 0;

static long long query_limit = 675; 

static const long long HARD_CAP = 200000;

static int n = 0;
static vector<int> hidden; 



void log_metrics() {
    try {
        tout << "queries=" << queries << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {
        
    }
}



void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}




struct Rng {
    unsigned long long state;
    Rng(unsigned long long seed) : state(seed) {}
    unsigned long long next() {
        state = state * 6364136223846793005ULL + 1442695040888963407ULL;
        return state;
    }
    int next_bit() {
        return (next() >> 32) & 1;
    }
} rng_gen(17052022ULL);

int main(int argc, char* argv[]) {
    
    registerInteraction(argc, argv);
    atexit(log_metrics);

    
    n = inf.readInt();
    string token = inf.readToken(); 

    
    log_metrics();

    
    if (token == "ADAPTIVE") {
        
        
        
        
        
        hidden.resize(n);
        for (int i = 0; i < n; ++i) {
            hidden[i] = rng_gen.next_bit();
        }
    } else {
        
        if ((int)token.size() != n) {
            finish(_fail, format("Generator string length %d does not match n=%d", (int)token.size(), n));
        }
        hidden.resize(n);
        for (int i = 0; i < n; ++i) {
            if (token[i] == 'T') hidden[i] = 1;
            else if (token[i] == 'F') hidden[i] = 0;
            else finish(_fail, "Invalid character in generator string");
        }
    }

    
    cout << n << endl;

    
    while (true) {
        string s;
        
        
        if (!(cin >> s)) {
            
            finish(_wa, "Unexpected EOF: solution terminated without finding the answer");
        }

        queries++;
        log_metrics(); 

        
        if (queries > HARD_CAP) {
            finish(_pe, "Hard query limit exceeded (infinite loop protection)");
        }

        
        if ((int)s.size() != n) {
            finish(_wa, format("Invalid query length: expected %d, got %d", n, (int)s.size()));
        }

        
        int matches = 0;
        for (int i = 0; i < n; ++i) {
            int val = -1;
            if (s[i] == 'T') val = 1;
            else if (s[i] == 'F') val = 0;
            else {
                finish(_wa, "Invalid character in query string (expected 'T' or 'F')");
            }

            if (val == hidden[i]) {
                matches++;
            }
        }

        
        cout << matches << endl;

        
        if (matches == n) {
            finish(_ok, format("Correct! Solved in %lld queries.", queries));
        }

        
        
    }

    return 0;
}


Test generator (C++):
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char* argv[]) {
    
    registerGen(argc, argv, 1);

    
    
    string mode = opt<string>("mode", "non");
    
    int n = opt<int>("n", -1);
    
    
    string seed_str = (argc > 1 ? string(argv[1]) : "");

    
    if (n == -1) {
        if (seed_str == "1") {
            n = 1;
        } else if (seed_str == "2" || seed_str == "3" || seed_str == "4") {
            n = 1000;
        } else {
            
            
            if (rnd.next(4) == 0) n = rnd.next(1, 1000);
            else n = 1000;
        }
    }

    
    cout << n << endl;

    if (mode == "adp") {
        
        
        
        cout << "ADAPTIVE" << endl;
    } else {
        
        
        string s;
        s.reserve(n);

        
        if (seed_str == "1" && n == 1) {
            s = "T";
        } else if (seed_str == "2" && n == 1000) {
            s = string(n, 'T');
        } else if (seed_str == "3" && n == 1000) {
            s = string(n, 'F');
        } else if (seed_str == "4" && n == 1000) {
            
            for (int i = 0; i < n; ++i) s += (i % 2 == 0 ? 'T' : 'F');
        } else {
            
            int strategy = rnd.next(100);
            
            if (strategy < 5) {
                
                s = string(n, 'T');
            } else if (strategy < 10) {
                
                s = string(n, 'F');
            } else if (strategy < 20) {
                
                for (int i = 0; i < n; ++i) s += (i % 2 == 0 ? 'T' : 'F');
            } else if (strategy < 60) {
                
                for (int i = 0; i < n; ++i) s += (rnd.next(2) ? 'T' : 'F');
            } else if (strategy < 80) {
                
                for (int i = 0; i < n; ++i) s += (rnd.next(10) > 0 ? 'T' : 'F');
            } else {
                
                int block_size = rnd.next(2, max(3, n / 10));
                char current = (rnd.next(2) ? 'T' : 'F');
                for (int i = 0; i < n; ++i) {
                    if (i > 0 && i % block_size == 0) {
                        current = (current == 'T' ? 'F' : 'T');
                    }
                    s += current;
                }
            }
        }
        cout << s << endl;
    }

    return 0;
}