#K44852. Matrix Generation
Matrix Generation
Matrix Generation
You are given an integer T representing the number of test cases. For each test case, two integers N and K are provided. Your task is to generate an N × N matrix where the element at the i-th row and j-th column is computed as
\((i + j) \times K\)
with i
and j
being 0-indexed. Print the matrix for each test case. Each row of the matrix should be printed on a separate line, with values separated by a space. Separate outputs of different test cases by an empty line.
inputFormat
The input begins with a single integer T representing the number of test cases. For each test case, there is a line containing two space-separated integers N and K.
outputFormat
For each test case, output the generated matrix. The matrix consists of N lines; each line contains N space-separated integers. Print an empty line after each test case's output (including after the last test case).
## sample3
3 2
2 5
1 3
0 2 4
2 4 6
4 6 8
0 5
5 10
0
</p>