Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (*x*, *y*), he can move to (or attack) positions (*x* + 1, *y*), (*x*–1, *y*), (*x*, *y* + 1) and (*x*, *y*–1).

Iahub wants to know how many Coders can be placed on an *n* × *n* chessboard, so that no Coder attacks any other Coder.
The first line contains an integer *n* (1 ≤ *n* ≤ 1000).
def get():
    return list(map(int, input().split()))
def intput():
    return int(input())
dRow = [ -1, 0, 1, 0]#0 :DOWN 0 ,1 RIGHT , 2 UP ,3 LEFT
dCol = [ 0, 1, 0, -1]

def main():
    for _ in range(intput()):
       n=intput()
       vis=[['.' for _ in range(n)] for _ in range(n)]
       s=0
       for r in range(n):
           for c in range(n):
                     ans=True
                     for i in range(4):
                         x=c+dCol[i]
                         y=r+dRow[i]
                         if (x<0  or y<0 or y>=n or x>=n):
                             continue
                         ans&=(vis[y][x]!='C')
                     if (ans ):
                         vis[r][c]='C'
                         s+=1
       print(s)
       for r in range(n):
        print    (''.join(vis[r]))




main()
