Madoka decided to participate in an underground sports programming competition. And there was exactly one task in it:

A square table of size $n \times n$, where $n$ is a multiple of $k$, is called good if only the characters '.' and 'X' are written in it, as well as in any subtable of size $1 \times k$ or $k \times 1$, there is at least one character 'X'. In other words, among any $k$ consecutive vertical or horizontal cells, there must be at least one containing the character 'X'.

Output any good table that has the minimum possible number of characters 'X', and also the symbol 'X' is written in the cell $(r, c)$. Rows are numbered from $1$ to $n$ from top to bottom, columns are numbered from $1$ to $n$ from left to right.


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. Description of the test cases follows.

The first and the only line of each test case contains four integers $n$, $k$, $r$, $c$ ($1 \le n \le 500, 1 \le k \le n, 1 \le r, c \le n$) — the size of the table, the integer $k$ and the coordinates of the cell, which must contain the character 'X'. It is guaranteed that $n$ is a multiple of $k$.

It is guaranteed that the sum of $n$ over all test cases does not exceed $500$.


-----Output-----

For each test case, output $n$ lines, each consisting of $n$ characters '.' and 'X', — the desired table. If there are several answers, then you can output anyone.


-----Examples-----

Input
3
3 3 3 2
2 1 1 2
6 3 4 2
Output
X..
..X
.X.
XX
XX
.X..X.
X..X..
..X..X
.X..X.
X..X..
..X..X


-----Note-----

Let's analyze the first test case.

The following tables can be printed as the correct answer:

X..

..X

.X.

or

..X

X..

.X.

It can be proved that there cannot be less than $3$ characters 'X' in the answer.

Note that the following table is invalid because cell $(3, 2)$ does not contain the character 'X':

X..

.X.

..X

In the second test case, the only correct table is:

XX

XX

Each subtable of size $1 \times 1$ must contain a 'X' character, so all characters in the table must be equal to 'X'.

Difficulty: EASY

Solutions:
t = int(input())
for i in range(t):
	(n, k, r, c) = map(int, input().split())
	l = []
	for i in range(k):
		s = i * '.' + 'X' + (k - i - 1) * '.'
		l.append(s)
	if c % k == 0:
		a = k - 1
	else:
		a = c % k - 1
	if r % k == 0:
		b = k - 1
	else:
		b = r % k - 1
	x = l[b]
	l[b] = l[a]
	l[a] = x
	for i in range(k):
		l[i] = l[i] * int(n / k)
	l = l * int(n / k)
	for i in l:
		print(i)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k, r, c) = map(int, input().split())
	(r, c) = ((r - 1) % k, (c - 1) % k)
	l = [['.'] * k for _ in range(k)]
	for i in range(k):
		l[i][i] = 'X'
	l[r][r] = '.'
	l[c][c] = '.'
	l[r][c] = 'X'
	l[c][r] = 'X'
	for i in range(n // k):
		for e in l:
			print(''.join(e) * (n // k))


t = int(input())
for _ in range(t):
	(n, k, r, c) = input().split()
	(n, k, r, c) = (int(n), int(k), int(r), int(c))
	r -= 1
	c -= 1
	r %= k
	c %= k
	matrix = [['.' for _ in range(n)] for __ in range(n)]
	for rid in range(n // k):
		radd = rid * k
		for cid in range(n // k):
			cadd = cid * k
			for i in range(k):
				matrix[radd + i][cadd + i] = 'X'
			matrix[radd + r][cadd + r] = '.'
			matrix[radd + c][cadd + c] = '.'
			matrix[radd + r][cadd + c] = 'X'
			matrix[radd + c][cadd + r] = 'X'
	for i in range(n):
		print(''.join(matrix[i]))


def solve():
	x = int(input())
	for __ in range(x):
		[n, k, r, c] = list(map(int, input().split()))
		rep = n // k
		r = (r - 1) % k
		c = (c - 1) % k
		sub = [['.'] * k for __ in range(k)]
		sub[r][c] = 'X'
		sub[c][r] = 'X'
		for i in range(k):
			for j in range(k):
				if i == j and i != r and (i != c):
					sub[i][j] = 'X'
					break
		for i in range(rep):
			for j in range(k):
				print(''.join(sub[j]) * rep)
solve()


for i in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	r = (r - 1) % k
	c = (c - 1) % k
	d = n // k
	for l in range(d):
		for j in range(k):
			if j == r:
				print(('.' * c + 'X' + '.' * (k - c - 1)) * d)
			elif j == c:
				print(('.' * r + 'X' + '.' * (k - r - 1)) * d)
			else:
				print(('.' * j + 'X' + '.' * (k - j - 1)) * d)


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	L = []
	for i in range(n):
		L.append('')
	r -= 1
	c -= 1
	tar = [c]
	j = c + k
	while j < n:
		tar.append(j)
		j += k
	j = c - k
	while j >= 0:
		tar.append(j)
		j -= k
	tar.sort()
	tp = ''
	for i in range(n):
		if i in tar:
			tp += 'X'
		else:
			tp += '.'
	L[r] = tp
	for i in range(r + 1, n):
		temp = L[i - 1]
		tot = temp[1:] + temp[0]
		L[i] = tot
	for i in range(r - 1, -1, -1):
		temp = L[i + 1]
		tot = temp[n - 1] + temp[0:n - 1]
		L[i] = tot
	for i in range(n):
		print(L[i])


def f(n, k, r, c):
	r = r - 1
	c = c - 1
	r = r % k
	c = c % k
	A = []
	col = 0
	for i in range(k):
		if i == r:
			curr = '.' * c + 'X' + (k - c - 1) * '.'
		elif i != r and col != c:
			curr = '.' * col + 'X' + (k - col - 1) * '.'
			col += 1
		else:
			col += 1
			curr = '.' * col + 'X' + (k - col - 1) * '.'
			col += 1
		A.append(curr)
	mul = n // k
	for i in range(k):
		A[i] = A[i] * mul
	return A
tc = int(input())
while tc > 0:
	(n, k, r, c) = [int(i) for i in input().split(' ')]
	A = f(n, k, r, c)
	for i in range(n // k):
		for j in range(k):
			print(A[j])
	tc = tc - 1


for _ in range(int(input())):
	(n, k, r, c) = list(map(int, input().split()))
	ans = []
	for _ in range(n):
		ans.append(list('.' * n))
	ans[r - 1][c - 1] = 'X'
	col = c
	for i in range(0, r)[::-1]:
		for j in range(c - 1, n + c, k):
			ans[i][j % n] = 'X'
		c += 1
	c = col
	for i in range(r - 1, n):
		for j in range(c - 1, n + c, k):
			ans[i][j % n] = 'X'
		c -= 1
	print('\n'.join(list(map(''.join, ans))))


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	t = (r - 1) % k + c
	x = t % k
	s = ''
	for i in range(1, n + 1):
		if i % k == x:
			s += 'X'
		else:
			s += '.'
	print(s)
	for j in range(n - 1):
		s = s[1:] + s[0]
		print(s)


def main():
	length = int(input())
	for _ in range(length):
		(n, k, r, c) = list(map(int, input().split(' ')))
		res = [['.'] * n for _ in range(n)]
		solver((r - 1) % k, (c - 1) % k, res, k, n)
		for line in res:
			print(''.join(line))

def solver(r, c, grid, k, n):
	(_r, _c) = (0, 0)
	(arr_r, arr_c) = ([r], [c])
	for _ in range(k - 1):
		if _r == r:
			_r += 1
		if _c == c:
			_c += 1
		arr_r.append(_r)
		arr_c.append(_c)
		_r += 1
		_c += 1
	t = n // k
	for i in range(t ** 2):
		t_r = i // t
		t_c = i % t
		for j in range(len(arr_r)):
			_r = t_r * k + arr_r[j]
			_c = t_c * k + arr_c[j]
			grid[_r][_c] = 'X'
main()


from math import ceil
import sys
input = sys.stdin.readline

def print(*args, end='\n', sep=' ') -> None:
	sys.stdout.write(sep.join(map(str, args)) + end)

def Solve():
	for t in range(int(input())):
		(n, k, r, c) = map(int, input().split())
		z = n // k
		r %= k
		c %= k
		ss = [''] * k
		for i in range(k):
			s = ('.' * i + 'X' + '.' * (k - i - 1)) * z
			ss[i] = s
		(ss[c - 1], ss[r - 1]) = (ss[r - 1], ss[c - 1])
		ss = ss * z
		print(*ss, sep='\n')
Solve()


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	x = 0
	(r, c) = (r - 1, c - 1)
	p = ('X' + '.' * (k - 1)) * (n // k)
	matrix = []
	for i in range(n):
		s = p[x:n] + p[:x]
		matrix.append(s)
		x = (x + 1) % k
	idx = 0
	while matrix[(r + idx) % n][c] != 'X':
		idx += 1
	for i in range(n):
		print(matrix[(i + idx) % n])


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	(r, c) = ((r - 1) % k, (c - 1) % k)
	mat = [['.' for i in range(k)] for j in range(k)]
	mat[r][c] = 'X'
	(rowBool, colBool) = ([False] * k, [False] * k)
	rowBool[r] = colBool[c] = True
	for i in range(k):
		for j in range(k):
			if not rowBool[i] and (not colBool[j]):
				mat[i][j] = 'X'
				rowBool[i] = colBool[j] = True
	for _ in range(n // k):
		for j in range(k):
			print(''.join(mat[j] * (n // k)))


def fillrow(row, start):
	for i in range(row, n, k):
		for j in range(start, n, k):
			mat[i][j] = 'X'
for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	r -= 1
	c -= 1
	div = n // k
	mat = [['.' for i in range(n)] for j in range(n)]
	r = r - r // k * k
	c = c - c // k * k
	pos = set()
	for i in range(k):
		if i == r:
			continue
		pos.add(i)
	count = 0
	for i in range(k):
		if count == c:
			count += 1
		if i in pos:
			fillrow(i, count)
			count += 1
		else:
			fillrow(r, c)
	for i in range(n):
		print(''.join(mat[i]))


num = int(input())
for i in range(num):
	data = input()
	data = data.split(' ')
	n = int(data[0])
	k = int(data[1])
	r = int(data[2])
	c = int(data[3])
	fil = []
	ans = []
	if k == 1:
		for z in range(n):
			row = 'X' * n
			ans.append(row)
		print('\n'.join(ans))
	else:
		isTrues = True
		for z in range(k):
			row = ''
			if (z + 1 == r % k or (r % (z + 1) == 0 and z + 1 == k)) and isTrues:
				isTrues = False
				for j in range(k):
					if j + 1 == c % k or (c % (j + 1) == 0 and j + 1 == k):
						row += 'X'
					else:
						row += '.'
			else:
				isTrue = True
				for j in range(k):
					if j + 1 != c % k and j + 1 not in fil and isTrue:
						fil.append(j + 1)
						row += 'X'
						isTrue = False
					else:
						row += '.'
			row = row * int(n / k)
			ans.append(row)
		ans = ans * int(n / k)
		print('\n'.join(ans))


t = int(input())
for i in range(0, t):
	(n, k, r, s) = map(int, input().split())
	m = r % k
	if m == 0:
		m = k
	p = s % k
	if p == 0:
		p = k
	l = []
	if p + m - 2 > k - 1:
		bl = True
		j = 0
		while bl == True:
			if m + p - k - 2 - j < 0:
				break
			l.append((m + p - k - 2 - j) * '.' + 'X' + (2 * k + j - m - p + 1) * '.')
			j = j + 1
		for j in range(0, k - len(l)):
			l.append((k - j - 1) * '.' + 'X' + j * '.')
	else:
		bl2 = True
		j = 0
		while bl2 == True:
			if p + m - 2 - j < 0:
				break
			l.append((p + m - 2 - j) * '.' + 'X' + (k + 1 - p - m + j) * '.')
			j = j + 1
		for j in range(0, k - len(l)):
			l.append((k - j - 1) * '.' + 'X' + j * '.')
	for j in range(0, n):
		print(n // k * l[j % k])


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	(r, c) = (r - 1, c - 1)
	m = (r + c) % k
	arr = [['.'] * n for _ in range(n)]
	for d in range(m, 2 * n - 1, k):
		i = min(d, n - 1)
		for j in range(d - i, i + 1):
			arr[i][j] = 'X'
			i -= 1
	for i in arr:
		print(''.join(i))


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	l = [0 for j in range(n)]
	r -= 1
	c -= 1
	target = [c]
	j = c + k
	while j < n:
		target.append(j)
		j += k
	j = c - k
	while j >= 0:
		target.append(j)
		j -= k
	target.sort()
	temp = ''
	for j in range(n):
		if j in target:
			temp += 'X'
		else:
			temp += '.'
	l[r] = temp
	for j in range(r + 1, n):
		temp = l[j - 1]
		a = temp[1:] + temp[0]
		l[j] = a
	for j in range(r - 1, -1, -1):
		temp = l[j + 1]
		a = temp[n - 1] + temp[0:n - 1]
		l[j] = a
	for j in range(n):
		print(l[j])


for h in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	x = []
	r -= 1
	c -= 1
	for i in range(n):
		x.append(['.'] * (2 * n))
	x[r][c] = 'x'
	v = c + r
	i = v
	while i >= 0:
		x[0][i] = 'x'
		i -= k
	i = v
	while i < 2 * n:
		x[0][i] = 'x'
		i += k
	for i in range(2 * n):
		if x[0][i] == 'x':
			(a, b) = (0, i)
			while b >= 0 and a < n:
				x[a][b] = 'X'
				a += 1
				b -= 1
	for i in x:
		print(''.join(i[:n]))


def codeforces(n, k, r, c):
	c -= 1
	arr = ['.' for i in range(n)]
	ro = 0
	for i in range(r - 1):
		c = (c + 1) % n
	tp = c
	while ro < n:
		b = arr.copy()
		tc = tp
		while tc >= 0:
			b[tc] = 'X'
			tc -= k
		tc = tp
		while tc < n:
			b[tc] = 'X'
			tc += k
		tp = (tp - 1) % n
		print(''.join(b))
		ro += 1
t = int(input())
for test in range(t):
	(n, k, r, c) = [int(i) for i in input().split()]
	codeforces(n, k, r, c)


import sys
N = int(input())

def table(n, k, r, c):
	loc = (r - 1 + c - 1) % n
	loc = loc % k
	index = []
	while loc < n:
		index.append(loc)
		loc += k
	for _ in range(n):
		line = ['.' for _ in range(n)]
		for i in index:
			line[i] = 'X'
		print(''.join(line))
		index = list(map(lambda x: x - 1 if x >= 0 else n - 2, index))
for _ in range(N):
	(n, k, r, c) = map(int, sys.stdin.readline().split())
	table(n, k, r, c)


for h in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	temp = []
	c -= 1
	r -= 1
	for i in range(n):
		temp.append(['.'] * (2 * n))
	temp[r][c] = 'X'
	var = c + r
	i = var
	while i >= 0:
		temp[0][i] = 'X'
		i -= k
	i = var
	while i < 2 * n:
		temp[0][i] = 'X'
		i += k
	for i in range(2 * n):
		if temp[0][i] == 'X':
			(w, q) = (i, 0)
			while w >= 0 and q < n:
				q += 1
				w -= 1
				temp[q - 1][w + 1] = 'X'
	for i in temp:
		print(''.join(i[:n]))


import math
t = int(input())
for tc in range(t):
	(n, k, r, c) = map(int, input().split())
	a = list()
	x = [['.'] * k for _ in range(k)]
	ra = r % k
	if ra == 0:
		row = k - 1
	else:
		row = ra - 1
	ca = c % k
	if ca == 0:
		col = k - 1
	else:
		col = ca - 1
	x[row][col] = 'X'
	if row == col:
		for i in range(k):
			for j in range(k):
				if i == j:
					x[i][j] = 'X'
		for i in range(n // k):
			for i in range(k):
				for j in range(n // k):
					print(''.join(x[i]), end='')
				print('')
	else:
		for i in range(k):
			for j in range(k):
				if i != row and j != col:
					if i == j:
						x[i][j] = 'X'
		rno = cno = 0
		for j in range(k):
			if 'X' not in x[j]:
				rno = j
		xt = [[x[j][i] for j in range(len(x))] for i in range(len(x[0]))]
		for z in range(k):
			if 'X' not in xt[z]:
				cno = z
		x[rno][cno] = 'X'
		for i in range(n // k):
			for i in range(k):
				for j in range(n // k):
					print(''.join(x[i]), end='')
				print('')


import sys

def solve():
	inp = sys.stdin.readline
	(n, k, r, c) = map(int, inp().split())
	x = -(r - 1 + c - 1)
	print('\n'.join((''.join(('X' if (i + j + x) % k == 0 else '.' for j in range(n))) for i in range(n))))

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


def solve(n, k, r, c):
	identifier = (r + c - 2) % k
	result = []
	for ri in range(n):
		row = ''
		for ci in range(n):
			if (ri + ci) % k == identifier:
				row += 'X'
			else:
				row += '.'
		result.append(row)
	return '\n'.join(result)
t = int(input())
for _ in range(t):
	(n, k, r, c) = [int(e) for e in input().split()]
	print(solve(n, k, r, c))


def toStr(s):
	new = ''
	for x in s:
		new += x
	return new
for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	r -= 1
	c -= 1
	grid = []
	for i in range(n):
		row = []
		for i in range(n):
			row.append('.')
		grid.append(row)
	for j in range(n // k):
		for i in range(n):
			grid[r][c] = 'X'
			r += 1
			c -= 1
			r = r % n
			c = c % n
		r += k
		r = r % n
	for i in range(n):
		print(toStr(grid[i]))


t = int(input())
for _ in range(t):
	(n, k, r, c) = [int(i) for i in input().split()]
	mat = [['.'] * n for _ in range(n)]
	r -= 1
	c -= 1
	rem = (r + c) % k
	for i in range(n):
		for j in range(n):
			if (i + j) % k == rem:
				mat[i][j] = 'X'
	for i in mat:
		print(''.join(i))


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	(r, c) = (r - 1, c - 1)
	y = (r + c) % k
	ans = [['.' for _ in range(n)] for _ in range(n)]
	for i in range(n):
		for j in range(n):
			if (i + j - y) % k == 0:
				ans[i][j] = 'X'
	for i in range(n):
		print(''.join(ans[i]))


for i in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	r -= 1
	c -= 1
	rc = (r + c) % k
	out = []
	for x in range(n):
		line = []
		for y in range(n):
			if (x + y) % k == rc:
				line.append('X')
			else:
				line.append('.')
		out.append(''.join(line))
	print('\n'.join(out))


def solve(n, k, a, b):
	phase = a + b - 2
	while phase < 0:
		phase += k
	phase %= k
	for _ in range(n):
		print(phase * '.' + 'X', end='')
		for _ in range(n // k - 1):
			print((k - 1) * '.' + 'X', end='')
		print((k - 1 - phase) * '.')
		phase += k - 1
		phase %= k
t = int(input())
for _ in range(t):
	(n, k, a, b) = map(int, input().split())
	solve(n, k, a, b)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k, r, c) = map(int, input().split())
	s = c + r - 1
	s = (s - 1) % k
	m = ['.'] * (n * 3)
	for x in range(s, n * 3, k):
		m[x] = 'X'
	mab = []
	for x in range(n):
		print(''.join((str(s) for s in m[x:x + n])))


def solve(n, k, rr, cc):
	r = (rr - 1) % k
	c = (cc - 1) % k
	for row in range(0, n):
		s = ''
		for col in range(0, n):
			isX = (col % k - c - (r - row % k)) % k == 0
			if isX:
				s += 'X'
			else:
				s += '.'
		print(s)
t = int(input())
for i in range(0, t):
	values = input().split(' ')
	solve(int(values[0]), int(values[1]), int(values[2]), int(values[3]))


t = int(input())
import sys
for i in sys.stdin:
	(n, k, r, c) = map(int, i.split())
	a = (r - 1 + c - 1) % k
	for i in range(n):
		aa = []
		for j in range(n):
			if (i + j) % k == a:
				aa.append('X')
			else:
				aa.append('.')
		print(''.join(aa))


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	n = range(n)
	for j in n:
		print(''.join(('X.'[(i + j) % k != (r + c - 2) % k] for i in n)))


t = int(input())
while t > 0:
	t -= 1
	(n, k, idx, jdx) = map(int, input().split())
	idx -= 1
	jdx -= 1
	a = []
	for i in range(n):
		a += [['.'] * n]
	for i in range(n):
		for j in range(n):
			if (i + j) % k == (idx + jdx) % k:
				a[i][j] = 'X'
	for i in range(n):
		print(''.join(a[i]))


t = int(input())
for _ in range(t):
	(n, k, r, c) = map(int, input().split())
	out = ''
	for i in range(n):
		for j in range(n):
			out += 'X' if (i + j - r - c + 2) % k == 0 else '.'
		out += '\n'
	print(out, end='')


for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	r -= 1
	c -= 1
	r %= k
	c %= k
	res = [['.' for _ in range(k)] for _ in range(k)]
	res[r][c] = 'X'
	j = 0
	for i in range(k):
		if i == r:
			continue
		if j == c:
			j += 1
		res[i][j] = 'X'
		j += 1
	ANS = [['.' for _ in range(n)] for _ in range(n)]
	for ii in range(n // k):
		for i in range(k):
			for jj in range(n // k):
				for j in range(k):
					ANS[ii * k + i][jj * k + j] = res[i][j]
	for i in range(n):
		print(''.join(ANS[i]))


import sys
for _ in range(int(sys.stdin.readline())):
	(n, k, r, c) = map(int, sys.stdin.readline().strip().split())
	rem = (r + c - 2) % k
	for i in range(n):
		for j in range(n):
			if (i + j) % k == rem:
				sys.stdout.write('X')
			else:
				sys.stdout.write('.')
		sys.stdout.write('\n')


import sys
sys.setrecursionlimit(10 ** 6)
from collections import Counter, deque, defaultdict

def place_k(grid, n, k, r, c):
	grid[r][c] = 'X'
	c = (c + k) % n
	while grid[r][c] != 'X':
		grid[r][c] = 'X'
		c = (c + k) % n
ip = sys.stdin.readline
op = sys.stdout.write
t = int(ip())
res = []
for _ in range(t):
	(n, k, r, c) = [int(x) for x in ip().split()]
	grid = [['.' for _ in range(n)] for _ in range(n)]
	place_k(grid, n, k, r - 1, c - 1)
	c1 = (c + n - 1) % n
	for i in range(r - 2, -1, -1):
		c1 = (c1 + 1) % n
		place_k(grid, n, k, i, c1)
	c2 = (c + n - 2) % n
	for i in range(r, n):
		place_k(grid, n, k, i, c2)
		c2 = (c2 + n - 1) % n
	res.append(grid)
for grid in res:
	for i in range(len(grid)):
		for j in range(len(grid)):
			op(grid[i][j])
		op('\n')


def xxx(a, x, n):
	(x, y) = (min(x, n), x - min(x, n))
	while y <= n:
		a[x][y] = 'X'
		y += 1
		x -= 1
	return 0
for _ in range(int(input())):
	(n, k, r, c) = map(int, input().split())
	a = [['.'] * n for _ in range(n)]
	for i in range((r + c - 2) % k, n * 2 - 1, k):
		xxx(a, i, n - 1)
	for i in range(n):
		print(*a[i], sep='')