Language: C++

#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME_SHORT 10007
#define PRIME 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

const bool debug = false;

void rar(int n, int* a);
void rar2(int n, int m, int** a);

int ipow(int base, int exp);
int left(int current, bool swap);
int right(int current, bool swap);
int griddist(int x, int y, int s, int t);
int griddist(pii one, pii two);
double sqeucldist(double x, double y, double s, double t);
double sqeucldist(pii one, pii two);
ull modadd(ull a, ull b, int mod);
ull modmult(ull a, ull b, int mod);

void set(string top, string bot, bool up, bool down)
{
    top += up?".":"#";
    bot += down?".":"#";
}

void set_front(string top, string bot, deque<char> ttop, deque<char> bbot, bool up, bool down)
{
    ttop.push_front(up?'.':'#');
    bbot.push_front(down?'.':'#');
    size_t n = ttop.size();
    char* ctop = new char[n];
    char* cbot = new char[n];
    for (size_t i = 0; i < n; ++i)
    {
        ctop[i] = ttop[i];
        cbot[i] = bbot[i];
    }
    top = string(ctop, n);
    bot = string(cbot, n);
}

void pop(string top, string bot)
{
    top.pop_back();
    bot.pop_back();
}

void pop_front(string top, string bot, deque<char> ttop, deque<char> bbot)
{
    ttop.pop_front();
    bbot.pop_front();
    size_t n = ttop.size();
    char* ctop = new char[n];
    char* cbot = new char[n];
    for (size_t i = 0; i < n; ++i)
    {
        ctop[i] = ttop[i];
        cbot[i] = bbot[i];
    }
    top = string(ctop, n);
    bot = string(cbot, n);
}

int main(void) {
    int n;
    cin >> n;

    pair< deque<char>, deque<char> > backend;

    //.. .# #. ##
    bool possible[4] = {true, true, true, true};
    pair<bool, bool> comb[4];
    comb.emplace_back(true, true);
    comb.emplace_back(true, false);
    comb.emplace_back(false, true);
    comb.emplace_back(false, false);

    string status;

    string top = "";
    string bot = "";

    for (int i = 0; i < 4; ++i)
    {
        set(top, bot, comb[i].first, comb[i].second);
        printf("%s\n%s\n", top, bot); fflush(stdout);
        cin >> status;
        if (status == "T") {
            pop(top, bot);
        } else if (status == "F") {
            possible[i] = false;
            pop(top, bot);
        } else if (status == "end") {
            return 0;
        }
    }

    std::vector<int> good;

    for (int i = 0; i < 4; ++i)
    {
        if (possible[i])
        {
            good.push_back(i);
        }
    }

    int wid = 1;
    bool btof = false;
    while (wid <= n) {

        //debug output
        if (debug)
        {
            cout << top << endl;
            cout << bot << endl;
        }

        bool found = false;
        if (!btof)
        {
            for (int i = 0; i < good.size(); ++i)
            {
                set_front(top, bot, backend.first, backend.second, comb[good[i]].first, comb[good[i]].second);
                printf("%s\n%s\n", top, bot); fflush(stdout);
                cin >> status;
                if (status == "T")
                {
                    found = true;
                    break;
                } else if (status == "F") {
                    pop_front(top, bot, backend.first, backend.second);
                    continue;
                } else if (status == "end") {
                    return 0;
                }
            }
            if (!found)
            {
                if (debug)
                {
                    cout << "error" << endl;
                }
                return 1;
            }
        } else {
            for (int i = 0; i < good.size(); ++i)
            {
                set(top, bot, comb[good[i]].first, comb[good[i]].second);
                printf("%s\n%s\n", top, bot); fflush(stdout);
                cin >> status;
                if (status == "T")
                {
                    found = true;
                    break;
                } else if (status == "F") {
                    pop(top, bot);
                    continue;
                } else if (status == "end") {
                    return 0;
                }
            }       
            if (!found)
            {
                deque<char> ttop, bbot;
                for (int i = 0; i < top.size(); ++i)
                {
                    ttop.push_back(top[i]);
                    bbot.push_back(bot[i]);
                }
                backend = make_pair(ttop, bbot);
                btof = true;
            }     
        }
    }

    return 0;
}

void rar(int n, int* a)
{
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    return;
}

void rar2(int n, int m, int** a)
{
    for (int i = 0; i < n; ++i)
    {
        a[i] = new int[m];
        for (int j = 0; j < m; ++j)
        {
            cin >> a[i][j];
        }
    }
    return;
}



















int ipow(int base, int exp) {
    int result = 1;
    while (exp)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        base *= base;
    }

    return result;
}
int left(int current, bool swap = false) {
    if(swap){
        return right(current, false);
    } else {
        return 2*current + 1;
    }
}
int right(int current, bool swap = false) {
    if(swap){
        return left(current, false);
    } else {
        return 2*(current+1);
    }
}
int griddist(int x, int y, int s, int t) {
    return abs(x-s) + abs(y-t);
}
int griddist(pii one, pii two) {
    return abs(one.first - two.first) + abs(one.second - two.second);
}
double sqeucldist(double x, double y, double s, double t) {
    double a = x-s;
    double b = y-t;
    return a*a+b*b;
}
double sqeucldist(pii one, pii two) {
    double a = one.first - two.first;
    double b = one.second - two.second;
    return a*a+b*b;
}

ull modadd(ull a, ull b, int mod) {
    return (a%mod + b%mod)%mod;
}
ull modmult(ull a, ull b, int mod) {
    return ((a%mod)*(b%mod))%mod;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:104:10: error: request for member 'emplace_back' in 'comb', which is of non-class type 'std::pair<bool, bool> [4]'
  104 |     comb.emplace_back(true, true);
      |          ^~~~~~~~~~~~
a.cc:105:10: error: request for member 'emplace_back' in 'comb', which is of non-class type 'std::pair<bool, bool> [4]'
  105 |     comb.emplace_back(true, false);
      |          ^~~~~~~~~~~~
a.cc:106:10: error: request for member 'emplace_back' in 'comb', which is of non-class type 'std::pair<bool, bool> [4]'
  106 |     comb.emplace_back(false, true);
      |          ^~~~~~~~~~~~
a.cc:107:10: error: request for member 'emplace_back' in 'comb', which is of non-class type 'std::pair<bool, bool> [4]'
  107 |     comb.emplace_back(false, false);
      |          ^~~~~~~~~~~~