Problem:
 Score : 150 points    Problem Statement  There is a long blackboard with 2 rows and N columns in a classroom of Kyoto University. 
  This blackboard is so long that it is impossible to tell which cells are already used and which unused.  Recently, a blackboard retrieval device was installed at the classroom. 
  To use this device, you type a search query that forms a rectangle with 2 rows and any length of columns, where each cell is used or unused. 
  When you input a query, the decive answers whether the rectangle that corresponds to the query exists in the blackboard. 
  Here, for a rectangle that corresponds to a search query, if two integer i, j ( i < j ) exist
  and the rectangle equals to the partial blackboard between column i and j ,
  the rectangle is called a sub-blackboard of the blackboard.  You are currently preparing for a presentation at this classroom.
  To make the presentation go well, you decided to write a program to detect the status of the whole blackboard using the retrieval device. 
  Since it takes time to use the device, you want to use it as few times as possible.  The status of the whole blackboard is already determined at the beginning and does not change while you are using the device.        Input  The first input is given in the following format:   N    N  (1 \leq N \leq 100) is an integer that represents the length of the blackboard.  After this input value, your program must print search queries. 
  A search query has the following format.   s_1  s_2   Here, s_1 represents the upper part of the blackboard and s_2 represents the lower. # in s_1 and s_2 represents the cell is already used and . represents the cell is still unused. 
  The lengths of s_1 and s_2 are arbitrary, but they must be the same. 
  Make sure to insert a line break at the end of the lines.  Every time your program prints a search query, a string that represents the search result of the device is returned in the followin format.   r    r is either T or F . 
  The meaning of each character is as follows.    T represents that the sub-blackboard that corresponds to the search query exists in the blackboard.   F represents that the sub-blackboard that corresponds to the search query does not exist in the blackboard.   If the search query equals to the whole blackboard or the number of the search queries exceeds the limit, string end is given instead of r .
  Once you receive this string, exit your program immediately. 
  If your program prints the whole blackboard as a search query before exceedin the limit, it is judged as Accepted . Note that the search query that represents the whole blackboard is also counted as the number of search queries.     Note that the output needs to be flushed every time the output is printed. 
  For example, In C/C++, search query s1 , s2 can be printed as follows.  printf("%s\n%s\n", s1, s2); fflush(stdout);  Make sure your program receive all the input from the device. Otherwise, the result may be Time Limit Exceeded .     Query Limit  The maximun number of search queries is 420 .
  If the number of queries exceeds the limit, the result will be Query Limit Exceeded .       Sample Input and Output  The following is an example where N=3 and the blackboard is as follows.  .#.
...  Note that your program does not know the state of the blackboard.     Output of your program  Input to your program  Explanation     3  The length of the blackboard is given    .. ##   Output a search query     F  The sub-blackboard does not exist    . .   Output a search query     T  The sub-blackboard exists    .. ..   Output a search query     F  The sub-blackboard does not exist    .# ..   Output a search query     T  The sub-blackboard exists    .#. ...   Output a search query     end  Exit your program because the above sub-blackboard equals to the whole blackboard.

Solution (Python):
import sys
readline = sys.stdin.readline

import itertools


DEBUG = False

N = int(readline())

class Interactive:
    def __init__(self):
        self.ques_cnt = 0
        self.create_data()
        
    def create_data(self):
        import random
        self.upper = ''.join(random.choice('.
        self.lower = ''.join(random.choice('.
        print('created upper:', self.upper)
        print('created lower:', self.lower)
        
    def resp_ques(self, *args):
        self.ques_cnt += 1
        if len(args) != 1:
            raise ValueError('不正な質問', args)
        S,T = args[0].split()
        L = len(S)
        for i in range(N):
            if S == self.lower[i:i+L] and T == self.upper[i:i+L]:
                if len(S) == N:
                    return 'end\n'
                else:
                    return 'T\n'
        return 'F\n'
            
    def resp_ans(self, *args):
        pass
            
if DEBUG:
    interactive = Interactive()
    
def question(*args, offset=None):
    if offset is None:
        print(*args, flush=True)
    else:
        print(offset, *args, flush=True)
    if DEBUG:
        resp = interactive.resp_ques(*args)
        print(resp)
        return resp
    else:
        return readline()
    
def answer(*args, offset=None):
    if offset is None:
        print(*args, flush=True)
    else:
        print(offset, *args, flush=True)
    if DEBUG:
        interactive.resp_ans(*args)
    else:
        exit()

col_patterns = tuple(itertools.product('.

def find_some_col():
    for S,T in col_patterns:
        resp = question(S + '\n' + T).rstrip()
        if resp == 'T':
            return S,T
        if resp == 'end':
            exit()

def extend_left(S,T):
    while True:
        flag = False
        for s,t in col_patterns:
            resp = question(s + S + '\n' + t + T).rstrip()
            if resp == 'T':
                flag = True
                S = s + S
                T = t + T
                break
            elif resp == 'end':
                exit()
        if not flag:
            return S,T

def extend_right(S,T):
    while True:
        flag = False
        for s,t in col_patterns:
            resp = question(S + s + '\n' + T + t).rstrip()
            if resp == 'T':
                flag = True
                S = S + s
                T = T + t
                break
            elif resp == 'end':
                exit()
        if not flag:
            return S,T

S,T = find_some_col()
S,T = extend_left(S,T)
S,T = extend_right(S,T)

Solution (Python):
import sys
flush = sys.stdout.flush
write = sys.stdout.write

N = int(input())

bb_1,bb_2 = "..
res_1,res_2 = "",""

def ask(s1,s2):
    write(s1+'\n'+s2+'\n')
    result = input()
    flush()
    if result=="end":
        exit()
    return result=="T"


while 1:
    for i in range(4):
        if ask(res_1+bb_1[i],res_2+bb_2[i]):
            res_1 += bb_1[i]
            res_2 += bb_2[i]
            break
    else:
        break


while 1:
    for i in range(4):
        if ask(bb_1[i]+res_1,bb_2[i]+res_2):
            res_1 = bb_1[i] + res_1
            res_2 = bb_2[i] + res_2
            break
    else:
        break

Solution (Python):
import sys
flush = sys.stdout.flush
write = sys.stdout.write
readline = sys.stdin.readline
N = int(readline())
Q0 = ""
Q1 = ""

q0 = "..
q1 = ".

def query(Q0, Q1):
    write("%s\n%s\n" % (Q0, Q1))
    flush()
    r = readline()
    if r == "end\n":
        exit(0)
    return r == "T\n"

while len(Q0) < N:
    for i in range(4):
        if query(Q0+q0[i], Q1+q1[i]):
            Q0 += q0[i]
            Q1 += q1[i]
            break
    else:
        break
while len(Q0) < N:
    for i in range(4):
        if query(q0[i]+Q0, q1[i]+Q1):
            Q0 = q0[i] + Q0
            Q1 = q1[i] + Q1
            break
    else:
        break
exit(1)

Solution (Python):
import sys
N = int(input())

s1 = ""
s2 = ""

sgn1 = "..
sgn2 = ".

flag = False
while True:
    if flag == False:
        flag = True
        for i in range(4):
            s1 += sgn1[i]
            s2 += sgn2[i]
            print(s1 + "\n" + s2)
            r = input()
            if r == "end":
                sys.exit(0)
            elif r == "T":
                flag = False
                break
            else:
                s1 = s1[:-1]
                s2 = s2[:-1]

    if flag == True:
        for i in range(4):
            s1 = sgn1[i] + s1
            s2 = sgn2[i] + s2
            print(s1 + "\n" + s2)
            r = input()
            if r == "end":
                sys.exit(0)
            elif r == "T":
                break
            else:
                s1 = s1[1:]
                s2 = s2[1:]

Solution (Python):
n = int(input())
s1=''
s2=''
ptn=[('.','.'),('.','
for i in range(n):
    for j in range(4):
        print(s1+ptn[j][0],flush=True)
        print(s2+ptn[j][1],flush=True)
        r = input()
        if r=='T':
            s1+=ptn[j][0]
            s2+=ptn[j][1]
            break
        elif r=='end':
            exit(0)
    else:
        break
for i in range(n):
    for j in range(4):
        print(ptn[j][0]+s1,flush=True)
        print(ptn[j][1]+s2,flush=True)
        r = input()
        if r=='T':
            s1=ptn[j][0]+s1
            s2=ptn[j][1]+s2
            break
        elif r=='end':
            exit(0)
    else:
        break

Solution (Python):
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    n = read()
    d = ['..', '.
    s1 = s2 = ''
    flag = True
    i = 0
    while True:
        if flag:
            print(s1 + d[i%4][0], flush=True)
            print(s2 + d[i%4][1], flush=True)
        else:
            print(d[i%4][0] + s1, flush=True)
            print(d[i%4][1] + s2, flush=True)
        r = input()
        if r == 'T':
            if flag:
                s1 = s1 + d[i%4][0]
                s2 = s2 + d[i%4][1]
            else:
                s1 = d[i%4][0] + s1
                s2 = d[i%4][1] + s2
            i = -1
        elif r == 'F':
            if i == 3:
                i = -1
                flag = False
        else:
            return
        i += 1

main()

Solution (Python):
import sys
N = int(raw_input())
upper = list()
lower = list()

right_end = 0
search_end = 0 
while True:
    if right_end == 0:
        for q in [['.', '.'], ['.', '
            print "".join(upper + [q[0]])
            print "".join(lower + [q[1]])
            sys.stdout.flush()

            r = raw_input()
            if r == 'T':
                upper.append(q[0])
                lower.append(q[1])
                break
            elif r == 'end':
                search_end = 1
                break
            if r == 'F' and q == ['
                right_end = 1
    else:
        for q in [['.', '.'], ['.', '
            print "".join([q[0]] + upper)
            print "".join([q[1]] + lower)
            sys.stdout.flush()
            
            r = raw_input()
            if r == 'T':
                upper.insert(0,q[0])
                lower.insert(0,q[1])
                break
            elif r == 'end':
                search_end = 1
                break
    if search_end == 1:
        break

Solution (Python):
import sys
from collections import deque
def query(s1,s2):
	print "{0}\n{1}".format("".join(s1),"".join(s2))
	sys.stdout.flush()
	return raw_input()
def solve():
	dss = [(".","."),(".","
	tmp_dss = []
	N = map(int,raw_input().split())
	for ds in dss:
		res = query([ds[0]],[ds[1]])
		if res == "T": tmp_dss.append(ds)
	dss = tmp_dss
	s1 = deque(dss[0][0]); s2 = deque(dss[0][1]) 
	for _ in xrange(420):
		
		for ds1,ds2 in dss:
			s1.append(ds1); s2.append(ds2)
			res = query(s1,s2)
			if res == "end": return
			if res == "T": break
			s1.pop();s2.pop()
		else:
			break
	for _ in xrange(420):
		
		for ds1,ds2 in dss:
			s1.appendleft(ds1); s2.appendleft(ds2)
			res = query(s1,s2)
			if res == "end": return
			if res == "T": break
			s1.popleft();s2.popleft()
solve()

Solution (Python):
from sys import stdout
n = int(raw_input())
def req(b):
    print b[0]
    print b[1]
    stdout.flush()
    return raw_input().strip()
s = ['..', '.
a = ['', '']
while 1:
    for t in s:
        b = [a[0] + t[0], a[1] + t[1]]
        r = req(b)
        if r == 'end':
            quit()
        if r == 'T':
            a = b
            break
    else:
        break
while 1:
    for t in s:
        b = [t[0] + a[0], t[1] + a[1]]
        r = req(b)
        if r == 'end':
            quit()
        if r == 'T':
            a = b
            break
    else:
        break

Solution (Python):

import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll
import random

N = int(raw_input())
t = [[".","."], [".", "
s1, s2 = "", ""

left = True
for loop in xrange(421):
    random.shuffle(t)
    if left:
        for t1, t2 in t: 
            print "\n".join([s1 + t1, s2 + t2])
            sys.stdout.flush()
            res = raw_input()
            if res == "T":
                s1 += t1
                s2 += t2
                break
            if res == "end":
                exit()
        else:
            left = False

    if not left:
        for t1, t2 in t:
            print "\n".join([t1 + s1, t2 + s2])
            sys.stdout.flush()
            res = raw_input()
            if res == "T":
                s1 = t1 + s1
                s2 = t2 + s2
                break
            if res == "end":
                exit()

Solution (Python):
N = input()
empty = ["" for _ in range(2)]

def searchright(knowledge):
    for u in [".", "
        for l in [".", "
            hypothesis = [knowledge[0] + u, knowledge[1] + l]
            print("\n".join(hypothesis))
            p = input()
            if p == "T":
                return searchright(hypothesis)
            elif p=="end":
                exit()
    return knowledge

def searchleft(knowledge):
    for u in [".", "
        for l in [".", "
            hypothesis = [u + knowledge[0], l + knowledge[1]]
            print("\n".join(hypothesis))
            p = input()
            if p == "T":
                return searchleft(hypothesis)
            elif p=="end":
                exit()
    return knowledge

print(searchleft(searchright(empty)))