**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
t = int(input())
l1 = []

for _ in range(t):
    n, m = map(int, input().split())
    l = []

    for _ in range(n):
        l.append([int(i) for i in input().split()])

    if n > 1 and m > 1:
        for i in range(n):
            s = []
            for j in range(m):
                if i == 0:
                    if j == 0:
                        if l[i][j] > l[i][j+1] and l[i][j] > l[i+1][j]:
                            s.append(max(l[i][j+1], l[i+1][j]))
                        else:
                            s.append(l[i][j])
                    elif j == m - 1:
                        if l[i][j] > l[i][j-1] and l[i][j] > l[i+1][j]:
                            s.append(max(l[i][j-1], l[i+1][j]))
                        else:
                            s.append(l[i][j])
                    else:
                        if l[i][j] > l[i][j-1] and l[i][j] > l[i][j+1] and l[i][j] > l[i+1][j]:
                            s.append(max(l[i][j-1], l[i][j+1], l[i+1][j]))
                        else:
                            s.append(l[i][j])
                elif i == n - 1:
                    if j == 0:
                        if l[i][j] > l[i][j+1] and l[i][j] > l[i-1][j]:
                            s.append(max(l[i][j+1], l[i-1][j]))
                        else:
                            s.append(l[i][j])
                    elif j == m - 1:
                        if l[i][j] > l[i][j-1] and l[i][j] > l[i-1][j]:
                            s.append(max(l[i][j-1], l[i-1][j]))
                        else:
                            s.append(l[i][j])
                    else:
                        if l[i][j] > l[i][j-1] and l[i][j] > l[i][j+1] and l[i][j] > l[i-1][j]:
                            s.append(max(l[i][j-1], l[i][j+1], l[i-1][j]))
                        else:
                            s.append(l[i][j])
                else:
                    if j == 0:
                        if l[i][j] > l[i][j+1] and l[i][j] > l[i+1][j] and l[i][j] > l[i-1][j]:
                            s.append(max(l[i][j+1], l[i+1][j], l[i-1][j]))
                        else:
                            s.append(l[i][j])
                    elif j == m - 1:
                        if l[i][j] > l[i][j-1] and l[i][j] > l[i+1][j] and l[i][j] > l[i-1][j]:
                            s.append(max(l[i][j-1], l[i+1][j], l[i-1][j]))
                        else:
                            s.append(l[i][j])
                    else:
                        if l[i][j] > l[i][j-1] and l[i][j] > l[i][j+1] and l[i][j] > l[i+1][j] and l[i][j] > l[i-1][j]:
                            s.append(max(l[i][j-1], l[i][j+1], l[i+1][j], l[i-1][j]))
                        else:
                            s.append(l[i][j])
            l1.append(s)
    elif n > 1:
        for i in range(n):
            s = []
            if i == 0:
                if l[i] > l[i+1]:
                    s.append(l[i+1])
                else:
                    s.append(l[i])
            elif i == n - 1:
                if l[i] > l[i-1]:
                    s.append(l[i-1])
                else:
                    s.append(l[i])
            else:
                if l[i] > l[i+1] and l[i] > l[i-1]:
                    s.append(max(l[i+1], l[i-1]))
            l1.append(*s)
    else:
        s = []
        for i in range(m):
            if i == 0:
                if l[0][i] > l[0][i+1]:
                    s.append(l[0][i+1])
                else:
                    s.append(l[0][i])
            elif i == m - 1:
                if l[0][i] > l[0][i-1]:
                    s.append(l[0][i-1])
                else:
                    s.append(l[0][i])
            else:
                if l[0][i] > l[0][i+1] and l[0][i] > l[0][i-1]:
                    s.append(max(l[0][i+1], l[0][i-1]))
        l1.append(s)

for k in l1:
    print(*k)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
def print_matrix(matrix, n,m, width=1):
    for r in range(n):
        for c in range(m):
            print(str(matrix[r][c]).ljust(width), end=' ')
        print()

n = int(input())
for ll in range(n):
    s = input()
    a = []
    b,m = int(s.split()[0]), int(s.split()[1])
    for j in range(b):
        w = input()
        r = w.split()
        mur = []
        for ik in range(m):
            mur.append(int(r[ik]))
        a.append(mur)
    if b ==1 and m == 1:
        print_matrix(a,b,m)
        break
    if b==1 and m >1:
        a[0][0] = a[0][1]
        for j in range(1,m-1):
            if a[0][j] > a[0][j+1] and a[0][j] > a[0][j-1]:
                a[0][j] = max(a[0][j+1],a[0][j-1])
        a[0][m-1] = a[0][m-2]
    elif m == 1 and b>1:
        a[0][0] =a[1][0]
        for j in range(1,m-1):
            if a[j][0] > a[j-1][0] and a[j][0] > a[j+1][0]:
                a[j][0] = max( a[j-1][0] ,a[j+1][0])
        a[m-1][0] =a[m-2][0]
    else:
        for i in range(b):
            for j in range(m):
                if i == 0:
                    if j == 0:
                        if a[i][j] > a[i][j + 1] and a[i][j] > a[i + 1][j]:
                            a[i][j]  = max(a[i][j + 1],a[i + 1][j])
                    elif j == m - 1:
                        if a[i][j] > a[i][j - 1] and a[i][j] > a[i + 1][j]:
                            a[i][j]  = max(a[i][j - 1],a[i + 1][j])
                    else:
                        if j >= 1 and j < m - 1:
                            if a[i][j] > a[i][j + 1] and a[i][j] > a[i][j - 1] and a[i][j] > a[i + 1][j]:
                                a[i][j] = max(a[i][j + 1],a[i][j - 1],a[i + 1][j])
                elif i == b - 1:
                    if j == 0:
                        if a[i][j] > a[i][j + 1] and a[i][j] > a[i - 1][j]:
                            a[i][j] = max(a[i][j + 1],a[i - 1][j])
                    elif j == m - 1:
                        if a[i][j] > a[i][j - 1] and a[i][j] > a[i - 1][j]:
                            a[i][j] = max(a[i][j - 1],a[i - 1][j])
                    else:
                        if j >= 1 and j < m - 1:
                            if a[i][j] > a[i][j + 1] and a[i][j] > a[i][j - 1] and a[i][j] > a[i - 1][j]:
                                a[i][j] = max(a[i][j + 1],a[i][j - 1] ,a[i - 1][j])
                elif i >= 1 and i < b - 1:
                    if j == 0:
                        if a[i][j] > a[i][j + 1] and a[i][j] > a[i - 1][j] and a[i][j] > a[i + 1][j]:
                            a[i][j] = max( a[i][j + 1], a[i - 1][j],a[i + 1][j])
                    elif j == m - 1:
                        if a[i][j] > a[i][j - 1] and a[i][j] > a[i - 1][j] and a[i][j] > a[i + 1][j]:
                            a[i][j] = max( a[i][j - 1], a[i - 1][j], a[i + 1][j])
                    else:
                        if (a[i][j] > a[i][j - 1] and a[i][j] > a[i - 1][j] and a[i][j] > a[i + 1][j]
                                and a[i][j] > a[i][j + 1]):
                            a[i][j] = max( a[i][j - 1],a[i - 1][j],a[i + 1][j], a[i][j + 1])
    print_matrix(a,b,m)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
import java.lang.reflect.Array;
import java.util.*;

import static java.lang.System.in;
import static java.lang.System.out;
public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while( T > 0 ) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int[][] a = new int[n][m];
            for( int i = 0;i < n; i++ ) {
                for( int j = 0; j < m ; j++ ) {
                    a[i][j] = sc.nextInt();
                }
            }
            if( m == 1 && n == 1 ) continue;
            else if( m == 1 || n == 1 ) {
                if( n == 1 ) {
                    a[0][0] = Math.min(a[0][0], a[0][1]);
                    for( int i = 1; i < m-1 ; i++ ) {
                        a[0][i] = Math.min(a[0][i], Math.max(a[0][i+1], a[0][i-1]));
                    }
                    a[0][m-1] = Math.min(a[0][m-1], a[0][m-2]);
                }
                else {
                    a[0][0] = Math.min(a[0][0], a[1][0]);
                    for( int i = 1; i < n-1 ; i++ ) {
                        a[i][0] = Math.min(a[i][0], Math.max(a[i+1][0], a[i-1][0]));
                    }
                    a[n-1][0] = Math.min(a[n-1][0], a[n-2][0]);
                }
            }
            else {
                a[0][0] = Math.min(a[0][0], Math.max(a[0][1], a[1][0]));
                for( int j = 0; j < m-1; j++ ) {
                    if(a[0][j] > Math.max(a[1][j], a[0][j+1]) ) a[0][j] = Math.max(a[1][j], a[0][j+1]);
                }
                a[0][m-1] = Math.min(a[0][m-1], Math.max(a[0][m-2], a[1][m-1]));
//                a[0][m-1] = Math.min(a[0][m-1], Math.max(a[0][m-2], a[1][m-1]));
                for( int i = 1; i < n-1 ; i++ ) {
                    a[i][0] = Math.min(a[i][0], Math.max(Math.max(a[i][1], a[i-1][0]), a[i+1][0]));
                    for( int j = 1; j < m-1 ; j++ ) {
                        int x = Math.max(a[i+1][j], a[i-1][j]);
                        x = Math.max(Math.max(a[i][j+1], a[i][j-1]), x);
                        if (a[i][j] > x) a[i][j] = x;
//                        out.println();
                    }
                    a[i][m-1] = Math.min(a[i][m-1], Math.max(Math.max(a[i][m-2], a[i-1][m-1]), a[i+1][m-1]));
                }
                a[n-1][0] = Math.min(a[n-1][0], Math.max(a[n-1][1], a[n-2][0]));
                for( int j = 0; j < m-1; j++ ) {
                    if(a[n-1][j] > Math.max(a[n-2][j], a[n-1][j+1]) ) a[n-1][j] = Math.max(a[n-1][j+1], a[n-2][j]);
                }
                a[n-1][m-1] = Math.min(a[n-1][m-1], Math.max(a[n-1][m-2], a[n-2][m-1]));

            }
            for( int i = 0; i < n; i++ ) {
                for( int j = 0; j < m ; j++ ) {
                    out.print(a[i][j] + " ");
                }out.println();
            }
            T--;
        }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3
2 3 2
3 4 3
2 3 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
import java.util.*;
import java.util.Arrays;
public class codeforces {

    public static int GCD(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
    public static int LCM(int a, int b) {
        int gcd = GCD(a, b);
        return (a * b) / gcd;
    }
    public static boolean isPrime(long number) {
        if (number <= 1) {
            return false;
        }
        if (number <= 3) {
            return true;
        }
        if (number % 2 == 0 || number % 3 == 0) {
            return false;
        }
        for (long i = 5; i * i <= number; i += 6) {
            if (number % i == 0 || number % (i + 2) == 0) {
                return false;
            }
        }
        return true;
    }

    public static boolean isAdj(char a, char b){
        if((a == 'z' && b == 'a') || (a == 'a' && b == 'z')) return true;

        if((int)a + 1 == (int)b) return true;
        if((int)b + 1 == (int)a) return true;
        return false;

    }

    public static int sum(int a){
        int x = 0;
        while(a > 0){
            x += a%10;
            a = a/10;
        }
        return x;
    }

    public static boolean isVowel(char a){
        return (a == 'a'|| a == 'e');
    }
    public static int binaryStringToInt(String binaryStr) {
        return Integer.parseInt(binaryStr, 2);
    }

    public static boolean isSorted(String s){
        int n = s.length();
        for(int i=0; i<n-1; i++){
            if(s.charAt(i) > s.charAt(i+1)) return false;
        }
        return true;
    }

	public static void main (String[] args)
	{
		Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while(T-->0){
            int n = sc.nextInt();
            int m = sc.nextInt();

            int grid[][] = new int[n][m];

            for(int i=0; i<n; i++){
                for(int j=0; j<m; j++){
                    grid[i][j] = sc.nextInt();
                }
            }

            if(n == 1 && m == 1){
                System.out.println(grid[0][0]);
            }
            else if(n == 1){
                if(grid[0][0] > grid[0][1]) grid[0][0] = grid[0][1];
                for(int j=1; j<m-1; j++){
                    if(grid[0][j] > grid[0][j+1]) grid[0][j] = grid[0][j+1];
                }
                if(grid[0][m-2] < grid[0][m-1]) grid[0][m-1] = grid[0][m-2];

                for(int i[] : grid){
                    for(int j : i){
                        System.out.print(j + " ");
                    }
                    System.out.println();
                }

            } else if (m == 1){
                    if(grid[0][0] > grid[1][0]) grid[0][0] = grid[1][0];
                    for(int j=1; j<n-1; j++){
                        if(grid[j][0] > grid[j+1][0]) grid[j][0] = grid[j+1][0];
                    }
                    if(grid[n-2][0] < grid[n-1][0]) grid[n-1][0] = grid[n-2][0];

                for(int i[] : grid){
                    for(int j : i){
                        System.out.print(j + " ");
                    }
                    System.out.println();
                }
            }
            else{
                for(int i=0; i<n; i++){
                    for(int j=0; j<m; j++){
                        if(i < n-1){
                            if(i > 0){
                                if(j < m-1){
                                    if(j > 0){
                                        if((grid[i][j] > grid[i][j+1]) && (grid[i][j] > grid[i][j-1]) && (grid[i][j] > grid[i+1][j]) && (grid[i][j] > grid[i-1][j])){
                                            grid[i][j] = Math.max(Math.max(grid[i][j-1] , grid[i][j+1]), Math.max(grid[i-1][j] , grid[i+1][j]));
                                        }
                                    } else {
                                        if((grid[i][j] > grid[i][j+1]) && (grid[i][j] > grid[i+1][j]) && (grid[i][j] > grid[i-1][j])){
                                            grid[i][j] = Math.max(grid[i][j+1], Math.max(grid[i-1][j] , grid[i+1][j]));
                                        }
                                    }
                                } else {
                                    if((grid[i][j] > grid[i][j-1]) && (grid[i][j] > grid[i+1][j]) && (grid[i][j] > grid[i-1][j])){
                                        grid[i][j] = Math.max(grid[i][j-1], Math.max(grid[i-1][j] , grid[i+1][j]));
                                    }
                                }
                            } else {
                                if(j < m-1){
                                    if(j > 0){
                                        if((grid[i][j] > grid[i][j+1]) && (grid[i][j] > grid[i][j-1]) && (grid[i][j] > grid[i+1][j])){
                                            grid[i][j] = Math.max(Math.max(grid[i][j-1] , grid[i][j+1]), grid[i+1][j]);
                                        }
                                    } else {
                                        if((grid[i][j] > grid[i][j+1]) && (grid[i][j] > grid[i+1][j])){
                                            grid[i][j] = Math.max(grid[i][j+1], grid[i+1][j]);
                                        }
                                    }
                                } else {
                                    if((grid[i][j] > grid[i][j-1]) && (grid[i][j] > grid[i+1][j])){
                                        grid[i][j] = Math.max(grid[i][j-1],grid[i+1][j]);
                                    }
                                }
                            }
                        } else {
                            if(j < m-1){
                                if(j > 0){
                                    if((grid[i][j] > grid[i][j+1]) && (grid[i][j] > grid[i][j-1]) && (grid[i][j] > grid[i-1][j])){
                                        grid[i][j] = Math.max(Math.max(grid[i][j-1] , grid[i][j+1]), grid[i-1][j]);
                                    }
                                } else {
                                    if((grid[i][j] > grid[i][j+1])&& (grid[i][j] > grid[i-1][j])){
                                        grid[i][j] = Math.max(grid[i][j+1], grid[i-1][j]);
                                    }
                                }
                            } else {
                                if((grid[i][j] > grid[i][j-1]) && (grid[i][j] > grid[i-1][j])){
                                    grid[i][j] = Math.max(grid[i][j-1], grid[i-1][j]);
                                }
                            }
                        }
                    }
                }

                for(int i[] : grid){
                    for(int j : i){
                        System.out.print(j + " ");
                    }
                    System.out.println();
                }

            }
        }

        sc.close();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
3 3
10 9 10
9 8 9
10 9 10
2 2
100 101
102 103
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
from itertools import permutations
import os
import sys
from bisect import bisect
from io import BytesIO, IOBase
import math
from math import gcd
from itertools import combinations
from collections import Counter

def main():
    t = int(input())
    for _ in range(t):
        n,m=list(map(int, input().split()))
        mat=[]
        for i in range(n):
            mat.append(list(map(int, input().split())))
        for p in range(1000):
            for i in range(n):
                for j in range(m):

                    if i==0 and i==n-1 and j==0 and j==m-1:
                        pass
                    elif i==0 and i==n-1 and j==0 :

                        if mat[i][j]==max(mat[i][j],mat[i][j+1]):

                            mat[i][j]=mat[i][j+1]
                    elif i==0 and i==n-1 and j==m-1:

                        if mat[i][j]==max(mat[i][j],mat[i][j-1]):
                            mat[i][j]=mat[i][j-1]
                    elif i==0  and j==0 and j==m-1:
                        if mat[i][j]==max(mat[i][j],mat[i+1][j]):
                            mat[i][j]=mat[i+1][j]
                    elif  i==n-1 and j==0 and j==m-1:
                        if mat[i][j]==max(mat[i][j],mat[i-1][j]):
                            mat[i][j]=mat[i-1][j]
                    elif i==0 and j==0:
                        if max(mat[i][j],mat[i+1][j],mat[i][j+1])==mat[i][j]:
                            mat[i][j]=mat[i][j+1]
                    elif i==n-1 and j==m-1:
                        if max(mat[i][j],mat[i-1][j],mat[i][j-1])==mat[i][j]:
                            mat[i][j]=max(mat[i-1][j],mat[i][j-1])
                    elif i==0 and  j==m-1:
                        if max(mat[i][j],mat[i+1][j],mat[i][j-1])==mat[i][j]:
                            mat[i][j]=max(mat[i+1][j],mat[i][j-1])
                    elif i==n-1 and j==0:
                        if max(mat[i][j],mat[i-1][j],mat[i][j+1])==mat[i][j]:
                            mat[i][j]=max(mat[i-1][j],mat[i][j+1])
                    elif i==n-1:
                        if max(mat[i][j],mat[i-1][j],mat[i][j+1],mat[i][j-1])==mat[i][j]:
                            mat[i][j]=max(mat[i-1][j],mat[i][j+1],mat[i][j-1])
                    elif i==0:
                        if max(mat[i][j],mat[i+1][j],mat[i][j+1],mat[i][j-1])==mat[i][j]:
                            mat[i][j]=max(mat[i+1][j],mat[i][j+1],mat[i][j-1])
                    elif j==m-1:
                        if max(mat[i][j],mat[i-1][j],mat[i][j-1],mat[i+1][j])==mat[i][j]:
                            mat[i][j]=max(mat[i-1][j],mat[i][j-1],mat[i+1][j])
                    elif j==0:
                        if max(mat[i][j],mat[i-1][j],mat[i][j+1],mat[i+1][j])==mat[i][j]:
                            mat[i][j]=max(mat[i-1][j],mat[i][j+1],mat[i+1][j])
                    else:
                        if max(mat[i][j],mat[i-1][j],mat[i][j+1],mat[i][j-1],mat[i+1][j])==mat[i][j]:
                            mat[i][j]=max(mat[i-1][j],mat[i][j+1],mat[i][j-1],mat[i+1][j])
        for i in mat:
            print(*i)

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the buggy code, let's consider the following steps:

1. **Identify the Bug**: The buggy code has a logical error in the way it handles the stabilization process. It incorrectly compares and updates the values of the matrix, especially in the boundary conditions and when multiple cells have the same value.

2. **Edge Cases**:
   - **Single Row or Column**: The code might fail when the matrix has only one row or one column.
   - **Boundary Cells**: The code might not handle boundary cells correctly, especially when they are the highest value in their neighborhood.
   - **Equal Values**: The code might fail when there are multiple cells with the same highest value in their neighborhood.

3. **Construct a Small-Scale Test Input**:
   - We will create a matrix with a small size (e.g., 2x2 or 3x3) to ensure the test input is valid and small.
   - We will include a cell that is the highest value in its neighborhood and should be reduced, but the code might handle it incorrectly.

Let's construct a 3x3 matrix where the center cell is the highest value in its neighborhood:

```plaintext
1
3 3
1 1 1
1 5 1
1 1 1
```

### Explanation:
- The matrix is 3x3.
- The center cell (2,2) has the value 5, which is greater than all its neighbors (all 1s).
- The stabilization algorithm should reduce the center cell value by 1 in each iteration until it is no longer the highest value in its neighborhood.

This test input will expose the bug in the buggy code, as it should reduce the center cell value but might fail to do so correctly due to the incorrect logic in the boundary and neighborhood checks.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
"""
बुद्धिहीन तनु जानिके, सुमिरौं पवन कुमार।
बल-बुद्धि बिद्या देहु मोहिं, हरहु कलेस बिकार।।
"""

def solve():
    n,m  = map(int,input().split())
    a=[]
    for i in range(n):
        temp = list(map(int,input().split()))
        a.append(temp)
    # print(a)

    if (n==1 and m==1):
        print(a[0][0])
        return
    elif (n==1):
        a[0][0]=min(a[0][0],a[0][1])
        a[0][-1]=min(a[0][-1],a[0][-2])

        for i in range(1,m-1):
            a[0][i] = max(a[0][i-1],a[0][i+1])
        print(*a[0])
        return

    elif (m==1):
        for i in range(1,n-1):
            a[0][0] = min(a[0][0],a[1][0])
            a[-1][0] = min(a[-1][0],a[-2][0])

            a[i][0] = max(a[i-1][0],a[i+1][0])
        for i in range(n):
            print(a[i][0])
        return

    else:

        # print("*",a,"*")
        temp = a[0][0]
        k = max(a[1][0],a[0][1])
        if (k<temp):
            a[0][0] = k

        temp = a[-1][0]
        k = max(a[-1][1],a[-2][0])
        if (k<temp):
            a[-1][0] = k
        temp = a[0][-1]
        k = max(a[0][-2],a[1][-1])
        if (k<temp):
            a[0][-1] = k

        temp = a[-1][-1]
        k = max(a[-2][-1],a[-1][-2])
        if (k<temp):
            a[-1][-1] = k

        for i in range(1,m-1):
            temp = a[0][i]
            k = max(a[0][i-1],a[0][i+1],a[1][i])
            if (k<temp):
                a[0][i] = k
            temp = a[-1][i]
            k = max(a[-1][i-1],a[-1][i+1],a[-2][i])
            if (k<temp):
                a[-1][i] = k

        for i in range(1,n-1):
            temp = a[i][0]
            k = max(a[i-1][0],a[i+1][0],a[i][1])
            if (k<temp):
                a[i][0] = k
            temp = a[i][-1]
            k = max(a[i-1][-1],a[i+1][-1],a[i][-2])
            if (k<temp):
                a[i][-1] = k

            for j in range(1,m-1):
                temp = a[i][j]
                k = max(a[i-1][j],a[i+1][j],a[i][j-1],a[i][j+1])
                if (k<temp):
                    a[i][j] = k

        for i in range(n):
            for j in range(m):
                print(a[i][j],end=" ")
            print()

for _ in range(int(input())):
    solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
1 2
3 1
2 2
1 2
3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
import java.util.*;

public class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {

        int numberOfTestCases = sc.nextInt();
        for (int i = 0; i < numberOfTestCases; i++) {
            fn();
        }
    }
    public static void displaymat(int [][] mat)
    {
        for (int i = 0; i < mat.length; i++) {
            for (int j = 0; j < mat[0].length; j++) {
                System.out.print(mat[i][j] + " ");
            }
            System.out.println();
        }
    }

    public static void fn()
    {
      int n = sc.nextInt();
      int m = sc.nextInt();
      int mat [][] = new int [n][m];
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            mat[i][j] = sc.nextInt();
        }
      }

      if (n  == 1 && m == 1)
      {
        displaymat(mat);
      }
      else if(n == 1)
      {
         // just a single row
         int n1 = 0;
        int n2 = 0;
        for (int i = 0; i < n; i++) {
            if(i == 0)
            {
                n1 = 0;
                n2 = mat[0][1];
            }
            else if( i == n-1 )
            {
                n1 = mat[0][i-1];
                n2 = 0;
            }
            else
            {
                n1 = mat[0][i-1];
                n2 = mat[0][i+1];
            }
            if( n1  < mat[0][i]  && n2 <  mat[0][i])
            {
                mat[0][i] = Math.max(n1 , n2);
            }
        }
        displaymat(mat);
      }
      else if(m == 1)
      {
        // just one column
        int n1 = 0;
        int n2 = 0;
        for (int i = 0; i < m; i++) {
            if(i == 0)
            {
                n1 = 0;
                n2 = mat[1][0];
            }
            else if( i == n-1 )
            {
                n1 = mat[i-1][0];
                n2 = 0;
            }
            else
            {
                n1 = mat[i-1][0];
                n2 = mat[i+1][0];
            }
            if( n1  < mat[i][0]  && n2 <  mat[i][0])
            {
                mat[i][0] = Math.max(n1 , n2);
            }
        }
        displaymat(mat);
      }
      else
      {
            int n1 , n2 , n3, n4 = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                n1 = n2 = n3 = n4 = 0;
                if( i == 0 )
                {
                    // we are in the first row
                    if(j == 0 )
                    {
                        n3 = mat[0][1];
                        n4 = mat[1][0];
                    }
                    else if(j == m -1)
                    {
                        n1 = mat[0][j-1];
                        n4 = mat[1][j];
                    }
                    else
                    {
                        n1 = mat[0][j-1];
                        n3 = mat[0][j+1];
                        n4 = mat[1][j];
                    }
                }
                else if (i == n-1)
                {
                    if(j == 0 )
                    {
                        n2 = mat[i-1][0];
                        n3 = mat[i][1];
                    }
                    else if(j == m -1)
                    {
                        n2 = mat[i-1][j];
                        n1 = mat[i][j-1];
                    }
                    else
                    {
                        n1 = mat[i][j-1];
                        n2 = mat[i-1][j];
                        n3 = mat[i][j+1];
                    }
                }
                else if(j == 0 )
                {
                    n2 = mat[i-1][j];
                    n3 = mat[i][j+1];
                    n4 = mat[i+1][j];
                }
                else if(j == m -1)
                {
                    n1 = mat[i][j-1];
                    n2 = mat[i-1][j];
                    n4 = mat[i+1][j];
                }
                else
                {
                    n1 = mat[i][j-1];
                    n2 = mat[i-1][j];
                    n3 = mat[i][j+1];
                    n4 = mat[i+1][j];
                }

                if( n1  < mat[i][j]  && n2 < mat[i][j] && n3 < mat[i][j] && n4 < mat[i][j])
            {
                mat[i][j] = Math.max( Math.max(n1 , n2 ), Math.max(n3,n4));
            }
            }
        }
        displaymat(mat);
    }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
import java.util.Scanner;
import java.lang.Math;

public class question2 {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        for(int i = 0; i<t; i++){
            int m = scan.nextInt();
            int n = scan.nextInt();
            int[][] a = new int[n+2][m+2];
            for(int j = 0; j<=m+1; j++){
                for(int k = 0; k<=n+1; k++){
                    if(j==0 || j== m+1 || k == 0 || k == n+1){
                        a[k][j] = 1;
                    }
                    else{
                        a[k][j] = scan.nextInt();
                    }
                }
            }
            for (int r = 1; r < m+1; r++){
                for( int c = 1; c < n+1; c++){
                    if(a[c][r] > a[c-1][r] && a[c][r] > a[c+1][r] && a[c][r]> a[c][r+1] && a[c][r] > a[c][r-1]){
                        System.out.print(Math.max(Math.max(a[c-1][r], a[c+1][r]), Math.max(a[c][r-1], a[c][r-1])) + " ");
                    }
                    else{
                        System.out.print(a[c][r] + " ");
                    }
                }
                System.out.println();
            }
        }
        System.out.println();

    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3
10 9 10
9 8 9
10 9 10
```

**Explanation:**
This test case is designed to expose the bug in the buggy code. The matrix is set up such that the center cell (2, 2) is the only cell that is strictly greater than its neighbors. The stabilization algorithm should reduce this cell's value until it is no longer the peak. However, the buggy code does not correctly implement the stabilization process, and it will likely produce incorrect output.

- Initial matrix:
  ```
  10 9 10
  9 8 9
  10 9 10
  ```

- After stabilization, the matrix should be:
  ```
  10 9 10
  9 9 9
  10 9 10
  ```

The buggy code will likely fail to correctly update the center cell and its neighbors, leading to incorrect output.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
// ***  ... जय श्री राम ...  ***//

#include<bits/stdc++.h>
using namespace std;

// #define ll         long long int
#define int            int64_t
#define all(x)        x.begin(),x.end()
#define rall(x)       x.begin(),x.end()
#define forn(i,a,b)    for(int i = a ; i<b ; i++)
#define forr(j,c,d)   for(int j = c ; j>=d ; j--)
#define fora(a,b)     for(auto& a : b)
#define yes           cout<<"Yes"<<endl
#define no            cout<<"No"<<endl
#define YES           cout<<"YES"<<endl
#define NO            cout<<"NO"<<endl
#define pb            push_back
#define mvi           vector<int>
#define mvc           vector<char>
#define mvs           vector<string>
#define mpi           map<int,int>
#define mpc           map<char,int>
#define umps          unordred_map<int,int>
#define nn            cout<<"\n"

void change(int n,int m , vector<vector<int>>& v){

    while(true){
        int maxi = INT_MIN;
        int mi=-1;
        int mj = -1;

         forn(i,0,n){
            forn(j,0,m){
                int flag = 0;

                if(i<n-1 && v[i][j]<=v[i+1][j]) flag = 1;
                if(i>0 && v[i][j]<=v[i-1][j]) flag = 1;
                if(j>0 && v[i][j]<=v[i][j-1]) flag = 1;
                if(j<m-1 && v[i][j]<=v[i][j+1]) flag = 1;

                if(flag==0){
                if(v[i][j]>maxi || (v[i][j] == maxi && (i<mi || (i==mi && j<mj)))){
                    maxi = v[i][j];
                    mi = i;
                    mj  = j;
                }
            }

            }

        }

        if(mi==-1 && mj==-1) break;

        if(v[mi][mj]>INT_MIN){
            v[mi][mj] = v[mi][mj]-1;
        }
        else break;

    }
}
int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;

        vector<vector<int>> v(n,vector<int>(m));

        forn(i,0,n){
            forn(j,0,m){
                cin>>v[i][j];
            }
        }

        if(v[0][0]==1000000000  && v[0][1]==1){
           forn(i,0,n){
            forn(j,0,m){
                cout<<1<<" ";
            }
            nn;
        }
        }
        else {

        change(n,m,v);
        forn(i,0,n){
            forn(j,0,m){
                cout<<v[i][j]<<" ";
            }
            nn;
        }
        }

    }

    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2 2
1 2
2 1
2 3
1 2 3
4 5 6
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
#define Free_Palestine ios_base::sync_with_stdio(0) ; cout.tie(NULL) ; cin.tie(NULL) ;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std ;
using namespace __gnu_pbds ;
#define endl '\n'
#define F first
#define S second
#define int long long
#define inf INT64_MAX
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define fixed(n) fixed << setprecision(n)
const int dx[]={0,0,1,-1} ;
const int dy[]={1,-1,0,0} ;
string dir="RLDU" ;
const double PI=3.14159265358979323846264338327 ;
template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update> ;

const int Mod=1000000007 ;
const int N=2e5+5 ;

signed main(){ Free_Palestine

int tt=1 ; cin>> tt ;

while(tt--)
{
    int n,m ; cin>> n >> m ;
    int mat[n][m] ;

    for(int i=0 ; i<n ; i++)
        for(int j=0 ; j<m ; j++)
            cin>> mat[i][j] ;

    while(1)
    {
        set<pii> st ;

        for(int i=0 ; i<n ; i++)
        {
            for(int j=0 ; j<m ; j++)
            {
                bool f=1 ;

                if(i && mat[i-1][j]>=mat[i][j]) f=0 ;
                if(i+1<n && mat[i+1][j]>=mat[i][j]) f=0 ;
                if(j && mat[i][j-1]>=mat[i][j]) f=0 ;
                if(j+1<m && mat[i][j+1]>=mat[i][j]) f=0 ;

                if(f)
                    st.insert({i,j}) ;
            }
        }

        if((int)st.size()==0) break ;
        else
        {
            int mxx=-inf,i=(*st.begin()).F,j=(*st.begin()).S ;

            if(i) mxx=max(mxx,mat[i-1][j]) ;
            if(i+1<n) mxx=max(mxx,mat[i+1][j]) ;
            if(j) mxx=max(mxx,mat[i][j-1]) ;
            if(j+1<m) mxx=max(mxx,mat[i][j+1]) ;
            mat[i][j]=mxx ;
        }
    }

    for(int i=0 ; i<n ; i++)
    {
        for(int j=0 ; j<m ; j++)
            cout<< mat[i][j] << ' ' ; cout<< endl ;
    }
}
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3
2 1 2
1 3 1
2 1 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <valarray>
#define ll unsigned long long
#define int long long int
//#define double long double
using namespace std;

const int N = 101;
int n, m, ans;
int a[N][N];
int bx[] = { -1,0,1,0 };
int by[] = { 0,-1,0,1 };

void solve() {
	cin >> n >> m;
	memset(a, 0, sizeof a);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) cin >> a[i][j];
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			int ma = 0;
			for (int s = 0; s < 4; s++)
			{
				ma = max(ma, a[i+bx[s]][j+by[s]]);
			}
			if (ma >= a[i][j])continue;
			else {
				a[i][j] = ma;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			cout << a[i][j]<<' ';
		cout << endl;
	}
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) solve();
	return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes the bug in the given buggy code, we need to focus on scenarios where the algorithm might fail to correctly identify and stabilize the matrix. The main issue in the buggy code is that it does not correctly handle the iterative process of finding and decrementing the value of the cell that is strictly greater than its neighbors. The code only checks and modifies the matrix once, instead of repeatedly until no such cell exists.

Let's consider a small-scale test case that can expose this issue:

1. **Matrix with a clear peak value**: A matrix where one cell has a value that is strictly greater than all its neighbors, and this cell needs to be decremented multiple times before the algorithm terminates.
2. **Matrix with multiple peaks**: A matrix where there are multiple cells that are strictly greater than their neighbors, and the algorithm should correctly handle the order of operations.

Here is a small-scale test input that meets these criteria:

```plaintext
2
3 3
5 4 5
4 6 4
5 4 5
3 3
2 1 2
1 3 1
2 1 2
```

Explanation:
- **First Test Case**:
  - The matrix is:
    ```
    5 4 5
    4 6 4
    5 4 5
    ```
  - The cell (2,2) with value 6 is strictly greater than all its neighbors (4, 4, 4, 5). The algorithm should decrement this cell multiple times until it is no longer strictly greater than its neighbors. The expected output should be:
    ```
    3 3 3
    3 3 3
    3 3 3
    ```

- **Second Test Case**:
  - The matrix is:
    ```
    2 1 2
    1 3 1
    2 1 2
    ```
  - The cell (2,2) with value 3 is strictly greater than all its neighbors (1, 1, 1, 2). The algorithm should decrement this cell multiple times until it is no longer strictly greater than its neighbors. The expected output should be:
    ```
    1 1 1
    1 1 1
    1 1 1
    ```

This test input should effectively expose the bug in the buggy code, as it fails to handle the iterative nature of the stabilization process.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
	int t;
	cin>>t;
	for(int i=0;i<t;i++){
		int a[101][101] = {0};
		int n,m;
		cin>>n>>m;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
			cin>>a[i][j];
			}
		}
		if(n==1&&m==1){
			cout<<a[n][m]<<endl;
			continue;
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				int u,d,l,r;
				u=a[i-1][j];
				d=a[i+1][j];
				l=a[i][j-1];
				r=a[i][j+1];
				if(a[i][j]>u&&a[i][j]>d&&a[i][j]>r&&a[i][j]>l){
						a[i][j]=max(max(l,r),max(u,d));
				}

			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
			cout<<a[i][j]<<' ';
			}
			cout<<endl;
		}
	}
	return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
1 2
3 1
2 2
2 2
3 3
10 1 10
1 10 1
10 1 10
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
def compute_max_neighboring_matrix(matrix):
    n = len(matrix)
    m = len(matrix[0]) if matrix else 0

    # Initialize the result matrix with zeros
    max_matrix = [[0] * m for _ in range(n)]

    # Directions for neighbors: up, down, left, right
    directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]

    # Iterate through each cell in the matrix
    for i in range(n):
        for j in range(m):
            max_neighbor = float('-inf')  # Initialize max_neighbor with negative infinity

            # Check each neighbor
            for di, dj in directions:
                ni, nj = i + di, j + dj
                if 0 <= ni < n and 0 <= nj < m:
                    max_neighbor = max(max_neighbor, matrix[ni][nj])

            # Assign max_neighbor to corresponding cell in max_matrix
            max_matrix[i][j] = max_neighbor

    return max_matrix

t=int(input())
for _ in range(t):
    n,m= map(int,input().split())
    mat=[]
    for i in range(n):
        l=list(map(int,input().split()))
        mat.append(l)
    for j in range(100):
        maxmat=compute_max_neighboring_matrix(mat)
        for a in range(n):
            for b in range(m):
                if mat[a][b] >maxmat[a][b]:
                    mat[a][b] =maxmat[a][b]
    for row in mat:
        print(" ".join(map(str, row)))

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3
2 1 2
1 2 1
2 1 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
"""import math
from typing import List
from collections import defaultdict
from functools import cache
from sortedcontainers import SortedList"""

import math
from collections import defaultdict

import io, os

input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def inp_entero():
    return (int(input()))

def inp_string():
    return (input().decode()).rstrip()

def inp_vector_enteros():
    return (list(map(int, input().split())))

def mayor(n,m,mx,i,j):
    val = mx[i][j]
    for a in range(-1,2):
        for b in range(-1,2):
            if abs(a) + abs(b) == 1:
                f = i+a
                c = j+b
                if 0 <= f < n and 0 <= c < m:
                    #print(a,b,'..',f,c,mx[f][c])
                    if mx[f][c] >= val:
                        return False
    return True

def getvecinos(n,m,mx,i,j):
    vecinos = []
    for a in range(-1,2):
        for b in range(-1,2):
            if abs(a) + abs(b) == 1:
                f = i+a
                c = j+b
                if 0 <= f < n and 0 <= c < m:
                    vecinos.append(mx[f][c])
    return vecinos

def getcandidatos(n,m,mx):
    ret = []
    for i in range(n):
        for j in range(m):
            if mayor(n,m,mx,i,j):
                ret.append((i,j))
    return ret

n = int(input())
for i in range(n):
    v = inp_vector_enteros()
    n = v[0]
    m = v[1]
    mx = []
    for i in range(n):
        mx.append(inp_vector_enteros())

    candidatos = getcandidatos(n,m,mx)
    candidatos.sort()

    while len(candidatos) > 0:
        #print(candidatos)

        i = candidatos[0][0]
        nuevoscandidatos = []
        for a,b in candidatos:
            if a == i:
                nuevoscandidatos.append((a,b))
        #print(nuevoscandidatos)
        vecinos = getvecinos(n,m,mx,nuevoscandidatos[0][0],nuevoscandidatos[0][1])
        #print('vecinos',vecinos)

        valor = mx[nuevoscandidatos[0][0]][nuevoscandidatos[0][1]]
        #print(valor)
        mini = math.inf
        for x in vecinos:
            cc = valor - x
            mini = min(mini,cc)

        #print('mini',mini)

        mx[nuevoscandidatos[0][0]][nuevoscandidatos[0][1]] = valor - mini
        #print(mx)
        #print()
        candidatos.pop(0)

    for i in range(n):
        for j in range(m):
            print(mx[i][j],end=' ')
        print()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3
1 2 1
2 3 2
1 2 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
import java.util.*;

public class B {
    static class Cell implements Comparable<Cell> {
        int i, j, value;
        Cell(int i, int j, int value) {
            this.i = i;
            this.j = j;
            this.value = value;
        }

        @Override
        public int compareTo(Cell other) {
            if (this.value != other.value) {
                return Integer.compare(other.value, this.value); // Higher value first
            }
            if (this.i != other.i) {
                return Integer.compare(this.i, other.i);
            }
            return Integer.compare(this.j, other.j);
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt(); // number of test cases

        for (int testCase = 0; testCase < t; testCase++) {
            int n = scanner.nextInt(); // number of rows
            int m = scanner.nextInt(); // number of columns

            int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = scanner.nextInt();
                }
            }

            stabilizeMatrix(matrix);

            // Print the stabilized matrix
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    System.out.print(matrix[i][j] + " ");
                }
                System.out.println();
            }
        }
    }

    private static void stabilizeMatrix(int[][] matrix) {
        int n = matrix.length;
        int m = matrix[0].length;
        int[] dx = {-1, 0, 1, 0};
        int[] dy = {0, 1, 0, -1};

        while (true) {
            boolean found = false;
            PriorityQueue<Cell> pq = new PriorityQueue<>();

            // Find all cells that are strictly greater than their neighbors
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (isGreater(matrix, i, j, dx, dy)) {
                        pq.offer(new Cell(i, j, matrix[i][j]));
                    }
                }
            }

            if (pq.isEmpty()) {
                break;
            }

            Cell cell = pq.poll();
            int maxNeighborValue = Integer.MIN_VALUE;

            // Find the maximum value of the neighbors
            for (int k = 0; k < 4; k++) {
                int ni = cell.i + dx[k];
                int nj = cell.j + dy[k];
                if (ni >= 0 && ni < n && nj >= 0 && nj < m) {
                    maxNeighborValue = Math.max(maxNeighborValue, matrix[ni][nj]);
                }
            }

            // Update the value of the cell
            matrix[cell.i][cell.j] = maxNeighborValue;
            found = true;

            if (!found) {
                break;
            }
        }
    }

    private static boolean isGreater(int[][] matrix, int i, int j, int[] dx, int[] dy) {
        for (int k = 0; k < 4; k++) {
            int ni = i + dx[k];
            int nj = j + dy[k];
            if (ni >= 0 && ni < matrix.length && nj >= 0 && nj < matrix[0].length) {
                if (matrix[i][j] <= matrix[ni][nj]) {
                    return false;
                }
            }
        }
        return true;
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3
2 1 2
1 3 1
2 1 2
```

### Explanation:
This test case is designed to expose a potential bug in the stabilization algorithm. Here’s why it’s challenging:

1. **Symmetry and Equal Values**: The matrix is symmetric around the center, and the center cell (1, 1, 1) has a value of 3, which is greater than its neighbors. This setup ensures that the center cell will be the first to be selected for stabilization.

2. **Stabilization Steps**:
   - **Step 1**: The center cell (1, 1) is selected because it is strictly greater than its neighbors (1, 0), (1, 2), (0, 1), and (2, 1), which all have values of 1 or 2.
   - **Step 2**: The value of the center cell (1, 1) is reduced to 2 (the maximum value of its neighbors).
   - **Step 3**: The center cell (1, 1) is still strictly greater than its neighbors, so it is selected again and reduced to 1.
   - **Step 4**: Now, the center cell (1, 1) is equal to its neighbors, so no further stabilization is needed.

3. **Edge Case**: The bug in the code might occur if the algorithm incorrectly handles the scenario where a cell is equal to its neighbors after being reduced. The correct behavior should be to terminate the algorithm when no cell is strictly greater than its neighbors, but a faulty implementation might continue to process the cell, leading to incorrect results.

This test case is small and valid, making it easy to verify the correctness of the algorithm while exposing potential issues.