from math import ceil
for _ in range(int(input())):
    k=int(input())  
    m=ceil(k/2)
    if k==1:
        print('........')
        print('........')
        print('.XXX....')
        print('.XOX....')
        print('.XXX....')
        print('........')
        print('........')
        print('........',end='')
    elif k==2:
        print('........')
        print('........')
        print('.XXXX...')
        print('.XO.X...')
        print('.XXXX...')
        print('........')
        print('........')
        print('........',end='')
    elif k==3:
        print('........')
        print('........')
        print('.XXXXX..')
        print('.XO..X..')
        print('.XXXXX..')
        print('........')
        print('........')
        print('........',end='')
    elif k==4:
        print('........')
        print('........')
        print('.XXXXXX.')
        print('.XO...X.')
        print('.XXXXXX.')
        print('........')
        print('........')
        print('........',end='')
    elif k==5:
        print('........')
        print('........')
        print('.XXXXXXX')
        print('.XO....X')
        print('.XXXXXXX')
        print('........')
        print('........')
        print('........',end='')
    elif k==6:
        print('O...X...')
        print('..XXX...')
        print('XXX.....')
        print('........')
        print('........')
        print('........')
        print('........')
        print('........',end='')
    elif k==7:
        print('O...X...')
        print('...XX...')
        print('XXXX....')
        print('........')
        print('........')
        print('........')
        print('........')
        print('........',end='')
    elif k==8:
        print('O...X...')
        print('....X...')
        print('XXXXX...')
        print('........')
        print('........')
        print('........')
        print('........')
        print('........',end='')
    else:
        print('k>8')