import itertools
def main():
t = 0
inp:"list[int]" = []
with open("F_input.txt","r") as f:
t,*inp = map(int,f.readlines())
out = []
for i in range(t):
out.append(show(solve(inp[i])))
save(out)
def save(out:"list[list[str]]"):
with open("F_output.txt","w") as f:
f.write("\n".join(itertools.chain(*out)))
print("saved")
def create_empty():
return [[[False]*17 for _ in range(17)] for _ in range(7)]
def map_grid(i:int):
a = 17*17
x= i//a
y = (i%a)//17
z = (i%17)
return x,y,z
def key(x):
return x[0]+x[1]+x[2],x[0]+x[1],x[0]
points = [(x,y,z) for x in range(7) for y in range(17) for z in range(17)]
points.sort(key=key)
def solve(n:int):
grid:"list[list[list[bool]]]" = create_empty()
spir = iter(points)
for i in range(n):
if i*2<2023:
x,y,z = map_grid(i*2)
else:
while 1:
x,y,z =next(spir)
if grid[x][y][z] == False:
break
assert grid[x][y][z] == False
grid[x][y][z] = True
return grid
def show(grid:"list[list[list[bool]]]"):
out = []
for x in grid:
for y in x:
out.append("".join(["#" if z else "." for z in y]))
out.append("")
return out
main()