**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
for _ in range(int(input())):
    n ,m = map(int , input().split())
    arr = []

    for _ in range(n):
        row = input().strip()
        arr.append(row)
    if n==1 and arr[0][0] == arr[0][m-1]:
        print("Yes")
        continue

    W = all("W" in row for row in arr)
    B = all("B" in row for row in arr)

    if n>1 and (W or B):
        print("Yes")
    else:
        print("No")

**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 provided buggy code, let's analyze the code and identify potential edge cases and scenarios where the code might fail.

### Analysis of the Buggy Code
1. **Single Row Handling**:
   - The code checks if the first and last characters of the single row are the same. If they are, it prints "Yes".
   - This check is incomplete because it doesn't consider the possibility of the entire row being the same color.

2. **Multiple Rows Handling**:
   - The code checks if every row contains at least one 'W' and one 'B'.
   - If either condition is true, it prints "Yes".
   - This check is incorrect because it doesn't ensure that the entire grid can be made uniform.

### Challenging Test Input
To expose the bug, we need to create a test case where the grid has multiple rows, and the conditions in the buggy code are met, but the grid cannot be made uniform.

#### Test Case
- **Grid Size**: 2x2
- **Grid Content**:
  - First row: "W B"
  - Second row: "B W"

This test case meets the condition where each row contains both 'W' and 'B', but it is impossible to make the entire grid the same color with the given operations.

### Output
```plaintext
1
2 2
W B
B W
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Set.*;
import java.util.*;

public class B_Rectangle_Filling
{
    static final int MOD = 1000000007;
    static BufferedReader reader;

    static void solve(int t) throws IOException {
        String[] input = reader.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int m = Integer.parseInt(input[1]);
        char ar[][]=new char[n][m];
        for(int i=0;i<n;i++){
            String input1 = reader.readLine();
            for(int j=0;j<m;j++){
                ar[i][j]=input1.charAt(j);
            }
        }
        if(n==1){
            if(ar[0][m-1]==ar[0][0]){
            System.out.println("YES");
            }
            else{
                System.out.println("NO");
            }
            return;
        }
        if(m==1){
            if(ar[0][0]==ar[n-1][0]){
            System.out.println("YES");
            }
            else{
                System.out.println("NO");
            }
            return;
        }
        if(check('B', n, m,ar)||check('W', n, m,ar))
        {
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
        //long x=Long.parseLong(input[1]);
            // for (int i = 0; i < n; i++) {
        //     ar[i][1] = Long.parseLong(inputB[i]);
        // }
        // for(int i=0;i<n;i++){
        //     ar[i][2]=Long.parseLong(inputC[i]);
        // }
        // long ans=0;
        // int arr[]=new int[3];
        // Arrays.fill(arr,1);
        // for(int i=0;i<n;i++){
        //     if((x|ar[i][0])==x&&(arr[0]==1)){
        //         ans|=ar[i][0];
        //     }
        //     else{
        //         arr[0]=-1;
        //     }
        //     if((x|ar[i][1])==x&&arr[1]==1){
        //         ans|=ar[i][1];
        //     }
        //     else{
        //         arr[1]=-1;
        //     }
        //     if((x|ar[i][2])==x&&arr[2]==1){
        //         ans|=ar[i][2];
        //     }
        //     else{
        //         arr[2]=-1;
        //     }
        //     if(x==ans){
        //         System.out.println("YES");
        //        // System.out.println(i);
        //         return;
        //     }
        // }
    }
    public static boolean check(char c,int n,int m,char ar[][]){
        boolean first=ar[0][0]==c;
        boolean second=ar[0][m-1]==c;
        boolean third=ar[n-1][0]==c;
        boolean fourth=ar[n-1][m-1]==c;
        if((first&&third)||(fourth&&second)){
            return true;
        }
        boolean f=false;
        boolean s=false;
        boolean t=false;
        boolean fo=false;
        for(int k=0;k<n;k++){
            if(ar[k][m-1]==c){
                f=true;
            }
            if(ar[k][0]==c){
                s=true;
            }
        }
        for(int k=0;k<m;k++){
            if(ar[n-1][k]==c){
                t=true;
            }
            if(ar[0][k]==c){
                fo=true;
            }
        }
        if((first&&f&&t)||(second&&s&&t)||(third&&f&&fo)||(fourth&&s&&fo)){
            return true;
        }
        return false;
}
    public static boolean isprime(int j){
        int count=0;
        for(int i=1;i<=Math.sqrt(j);i++){
            if(j%i==0){
                count++;
            }
        }
        if(count>1)
            return false;
            return true;
        }
    public static long gcd(long a,long b){
        return b == 0 ? a : gcd(b, a % b);
    }
    public static void main(String[] args) throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(reader.readLine());
        while (t-- > 0) {
            solve(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
3
2 2
BW
WB
3 3
BWB
WBW
BWB
4 4
BWBW
WBWB
BWBW
WBWB
```

3
2 2
BW
WB
3 3
BWB
WBW
BWB
4 4
BWBW
WBWB
BWBW
WBWB


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static FastIO io = new FastIO();
    public static void main(String[] args) {
        int t = io.nextInt();
        while (t-- > 0) {
            solve();
        }
    }

    static void solve() {
        int n = io.nextInt();
        int m = io.nextInt();
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            String str = io.next();
            for (int j = 0; j < str.length(); j++) {
                arr[i][j] = str.charAt(j) == 'B' ? 1 : 0;
            }
        }

        boolean[] by = new boolean[n];
        boolean[] bx = new boolean[m];
        boolean[] wy = new boolean[n];
        boolean[] wx = new boolean[m];
        for (int i = 0; i < n; i++) {
            boolean b = false;
            boolean w = false;
            for (int j = 0; j < m; j++) {
                if (arr[i][j] == 1) {
                    b = true;
                }
                if (arr[i][j] == 0) {
                    w = true;
                }
            }
            if (b) by[i] = true;
            if (w) wy[i] = true;
        }

        for (int i = 0; i < m; i++) {
            boolean b = false;
            boolean w = false;
            for (int j = 0; j < n; j++) {
                if (arr[j][i] == 1) {
                    b = true;
                }
                if (arr[j][i] == 0) {
                    w = true;
                }
            }
            if (b) bx[i] = true;
            if (w) wx[i] = true;
        }

        boolean byy = true;
        boolean bxx = true;
        boolean wyy = true;
        boolean wxx = true;
        for (int i = 0; i < n; i++) {
            if (!by[i]) byy = false;
            if (!wy[i]) wyy = false;
        }

        for (int i = 0; i < m; i++) {
            if (!bx[i]) bxx = false;
            if (!wx[i]) wxx = false;
        }

        if ((bxx && byy) || (wxx && wyy)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}
class FastIO {
    public BufferedReader br;
    public StringTokenizer st;
    FastIO() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
}

**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
BW
WB
3 3
BBB
BBB
BBB
2 3
BBW
WBB
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define int ll
// #define mp make_pair
#define pb push_back
#define F first
#define S second
#define go ios_base::sync_with_stdio(false), cin.tie(0)
#define on_bits __builtin_popcount
#define on_bitsll __builtin_popcountll
#define endl "\n"
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define get_unique(v)                                 \
	{                                                 \
		sort(v.begin(), v.end());                     \
		v.erase(unique(v.begin(), v.end()), v.end()); \
	}
#define ins insert
#define log(x) (31 ^ __builtin_clz(x))
#define logll(x) (63 ^ __builtin_clzll(x))
#define vi vector<int>
#define vll vector<ll>
#define vp vector<pii>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int N = 3e5 + 7;
constexpr int mod = 998244353;
const ld OO = 1e9;
const int OOI = 1e9;
int n, m;
char c[501][501];
void AboModar()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			cin >> c[i][j];
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(c[i][m] == c[1][1] && c[i][m] == c[n][1])
		{
			cout << "YES\n";
			return;
		}
		if(c[i][1] == c[1][m] && c[i][1] == c[n][m])
		{
			cout << "YES\n";
			return;
		}
	}
	for(int i = 1; i <= m; i++)
	{
		if(c[1][i] == c[n][m] && c[1][i] == c[n][1])
		{
			cout << "YES\n";
			return;
		}
		if(c[n][i] == c[1][1] && c[n][i] == c[1][m])
		{
			cout << "YES\n";
			return;
		}
	}
	cout << "NO\n";
}
signed main()
{
	go;
	int t = 1;
	cin >> t;
	while (t--)
	{
		AboModar();
	}
	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
WB
BW
3 3
BBW
WBW
BWW
4 4
BWBW
WBWB
BWBW
WBWB
```

3
2 2
WB
BW
3 3
BBW
WBW
BWW
4 4
BWBW
WBWB
BWBW
WBWB


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

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

#define forn(iter,size) for(int iter = 0; iter < int(size); ++iter)

typedef long long ll;
typedef double du;
const int INF = int(1e9) + 9;

int checkW(char ch){return ch == 'W';}
int checkB(char ch){return ch == 'B';}

void solve(){
    int n,m;cin >> n >> m;
    vector<string> s(n);
    for(auto &e:s)cin >> e;
    vector<bool> u(3),d(3);
    bool wu = 0,bu = 0,wd = 0,bd = 0;
    bool wl = 0,bl = 0,wr = 0,br = 0;

    for(int x =1;x < m-1;++x){
        wu = checkW(s[0][x]);
        bu = checkB(s[0][x]);
        wd = checkW(s[n-1][x]);
        bd = checkB(s[n-1][x]);
    }

    for(int x = 1; x < n-1;++x){
        wl = checkW(s[x][0]);
        bl = checkB(s[x][0]);
        wr = checkW(s[x][m-1]);
        br = checkB(s[x][m-1]);
    }

    if((checkW(s[0][0]) && checkW(s[n-1][m-1])) ||
    (checkW(s[0][m-1]) && checkW(s[n-1][0]))||
    (wd && checkW(s[0][0]) && checkW(s[0][m-1]))||
    (wu && checkW(s[n-1][0]) && checkW(s[n-1][m-1]))||
    (checkB(s[0][0]) && checkB(s[n-1][m-1])) ||
    (checkB(s[0][m-1]) && checkB(s[n-1][0]))||
    (bd && checkB(s[0][0]) && checkB(s[0][m-1]))||
    (bu && checkB(s[n-1][0]) && checkB(s[n-1][m-1]))||

    (checkW(s[0][0]) && checkW(s[n-1][m-1])) ||
    (checkW(s[n-1][0]) && checkW(s[0][m-1]))||
    (wl && checkW(s[0][m-1]) && checkW(s[n-1][m-1]))||
    (wr && checkW(s[0][0]) && checkW(s[n-1][0]))||
    (checkB(s[0][0]) && checkB(s[n-1][m-1])) ||
    (checkB(s[n-1][0]) && checkB(s[0][m-1]))||
    (bl && checkB(s[0][m-1]) && checkB(s[n-1][m-1]))||
    (br && checkB(s[0][0]) && checkB(s[n-1][0]))
    )
        cout << "YES\n";
    else
        cout << "NO\n";

}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t;cin >> t;

    while(t--){
        solve();
    }
}

/*DROP

bool wt = 1;
        for(int y = m - 1;y >= 0; ++y)
            if(!wt)w[y] = 0;
            else if(s[x][y] == 'W' )wt = 0;
        bool bt = 1;
        for(int y = m - 1;y >= 0; ++y)
            if(!bt)b[y] = 0;
            else if(s[x][y] == 'B' )bt = 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
4
3 3
WBB
BBW
BBB
2 2
WB
BW
5 5
WBBBB
BWWWW
BBBWW
BBBWW
BBBWW
1 2
WB
```

4
3 3
WBB
BBW
BBB
2 2
WB
BW
5 5
WBBBB
BWWWW
BBBWW
BBBWW
BBBWW
1 2
WB


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
t=int(input())
for _ in range(t):
    flag=False
    n,m=map(int,input().split())
    L=[]
    for i in range(n):
        L.append(input())
        if i==0:
            x=L[0][0]
            y=L[0][m-1]
        else:
            if L[i][0]!=x or L[i][m-1]!=y:
                flag=True
    if _==20:
        print(L)
    if m==1:
        if L[0][0]==L[n-1][0]:
            print("yes")
        else:
            print("no")
    elif n==1:
        if L[0][0]==L[0][m-1]:
            print("yes")
        else:
            print("no")
    else:
        a=L[0][0]
        b=L[0][m-1]
        c=L[n-1][0]
        d=L[n-1][m-1]
        if a==d or b==c:
            print("Yes")
        elif a==b:
            if c in L[0]:
                print("Yes")
            elif b in L[n-1]:
                print("Yes")
            else:
                print("No")
        else:
            if flag==True:
                print("Yes")
            else:
                print("No")

**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
BWB
WBW
BWB
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
for i in range(int(input())):
    n,k=map(int,input().split())
    l=[]
    if n==1:
        ch=input()
        if ch[0]!=ch[-1]:
            print("NO")
        else:print("YES")
    else:
     for j in range(n):
        ch=input()
        l.append(set(ch))
     #l1=[len(s) for s in l]
     #print(l1)
     if all(len(h)==len(l[0]) for h in l) and l[0]!=l[-1]:

         print("NO")
     else:
         print("YES")

**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
WBW
BWB
WBW
```

### Explanation:
This test case is designed to expose the bug in the given buggy code. The input is a 3x3 grid with a specific pattern where the corners are white and the center is black, forming a checkerboard pattern.

1. **Corner Case Handling**: The grid is not a 1x1 grid, which means the code should not directly output "YES" or "NO" based on the first row and column.
2. **Checkerboard Pattern**: The pattern in the grid makes it impossible to make all squares the same color with the given operations. This is because any operation that changes the color of a subrectangle will always leave some squares in their original color, maintaining the checkerboard pattern.
3. **Buggy Code Logic**: The buggy code checks if all rows have the same set of characters and if the first and last rows are different. In this case, the sets of characters in each row are the same (`{'B', 'W'}`), but the first and last rows are identical, which should result in a "YES" according to the buggy code. However, the correct output should be "NO" because it's impossible to make all squares the same color.

This test case will help identify the logical flaw in the buggy code.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main {
    public static int mod = (int)1e9+7;

    public static void main(String[] args) throws Exception {
        fastscanner sc = new fastscanner();
        PrintWriter pr = new PrintWriter(System.out);
        int t = sc.nextInt();

        while (t-- != 0) {

            int n,m;
            n=sc.nextInt();
            m=sc.nextInt();
            char a[][]=new char[n][m];
            for(int i=0;i<n;i++){
                char c[]=sc.next().toCharArray();
                for(int j=0;j<m;j++) a[i][j]=c[j];
            }

            if(a[0][0]==a[n-1][m-1]) pr.println("YES");
            else{
                char tmp=a[n-1][m-1];
                boolean fr=false,fc=false;
                for(int i=1;i<m;i++){
                    if(a[0][i]==tmp){
                        fc=true;break;
                    }
                }
                for(int i=1;i<n;i++){
                    if(a[i][0]==tmp){
                        fr=true;break;
                    }
                }

                if(fr&&fc) pr.println("YES");
                else{
                    tmp=a[0][0];
                    fr=false;fc=false;
                    for(int i=m-2;i>=0;i--){
                        if(a[n-1][i]==tmp){
                            fc=true;break;
                        }
                    }
                    for(int i=n-2;i>=0;i++){
                        if(a[m-1][0]==tmp){
                            fr=true;break;
                        }
                    }
                    pr.println(fr&&fc?"YES":"NO");
                }

            }

        }
        pr.flush();
    }

    static boolean primeCheck(int a){
        if(a==2||a==3) return true;
        if(a==1||a%2==0||a%3==0) return false;
        for(int i=5;i*i<=a;i+=6){
            if(a%i==0||a%(i+2)==0) return false;
        }
        return true;
    }

    static long divisorCount(long a){
        long cnt=0;
        for(long i=1;i*i<=a;i++){
            if(a%i==0){
                if(i*i==a) cnt++;
                else cnt+=2;
                cnt%=mod;
            }
        }
        return cnt;
    }

    static long nc2(int n){
        if(n<2) return 0;
        return ((long) n *(n-1))/2;
    }
    static long nCr(long n,long r){
        if(n<r) return 0;
        if(r==0) return 1;
        return ((fact((int)n)*modInv( fact((int)r)))%mod*modInv( fact((int)(n-r))))%mod;
    }

    public static long ncr(long n,long r){
        if(n-r<r)
            return ncr(n,n-r);
        long res=1;
        for(long i=n-r+1;i<=n;++i){
            res*=i;
            res%=mod;
        }
        for(long i=2;i<=r;++i){
            res*=power(i,mod-2);
            res%=mod;
        }
        return res;
    }

    static long modInv(long n){
        return power(n,mod-2)%mod;
    }

    static long power(long a,long b){
        a=a%mod;
        long res=1;
        while(b>0){
            if((b&1)!=0) res=(res*a)%mod;
            b>>=1;
            a=(a*a)%mod;
        }
        return res%mod;
    }

    static long binExp(int a ,int b){
        long res=1;
        while(b>0){
            if((b&1)!=0) res*=a;
            a*=a;
            b>>=1;
        }
        return res%mod;
    }

    public static int fact(int n)
    {
        int res = 1, i;
        for (i = 2; i <= n; i++) res =(res*i)%mod;
        return res%mod;
    }

    public static int[] sieve(int n){
        boolean []isPrime=new boolean[n+1];
        for(int i=2;i<=n;i++) isPrime[i]=true;
        isPrime[0]=isPrime[1]=false;
        for(int i=2;i<=n;i++){
            if(isPrime[i]&&((long) i *i)<=n){
                for(int j=i*i;j<=n;j+=i) isPrime[j]=false;
            }
        }
        int []primes=new int[n];
        primes[0]=2;
        int cnt=1;
        for(int i=3;i<=n;i+=2){
            if(isPrime[i]){
                primes[cnt]=i;cnt++;
            }
        }
        return primes;
    }

    public static long gcd(long a,long b){
        while(b>0){
            long tmp=b;
            b=a%b;
            a=tmp;
        }
        return a;
    }

    public static long gcdArray(int[] a){
        long gcd=a[0];
        for(int i=1;i<a.length;i++){
            gcd=gcd(gcd,a[i]);
        }
        return gcd;
    }

}

class fastscanner
{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    String next()
    {
        while (st == null || !st.hasMoreTokens())
        {
            try {

                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e) {}
        }
        return st.nextToken();
    }
    int nextInt()
    {
        return Integer.parseInt(next());
    }
    float nextFloat()
    {
        return Float.parseFloat(next());
    }
    long nextLong()
    {
        return Long.parseLong(next());
    }
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
    String nextLine()
    {
        String s = "";
        try {
            s = br.readLine();
        }
        catch (IOException e) {}
        return s;
    }
}

**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 given buggy code, we need to focus on edge cases and scenarios that are likely to cause the code to fail. The buggy code seems to have issues with how it handles the boundary conditions and the logic for checking if the grid can be made uniform.

### Analysis of the Buggy Code
1. **Initial Check**: The code checks if the top-left and bottom-right corners are the same color. If they are, it immediately returns "YES". This is incorrect because there could be other configurations where the grid can be made uniform even if these corners are not the same color.
2. **Boundary Check**: The code then checks if the bottom-right corner color can be found in the first row or column, and similarly for the top-left corner color. This logic is flawed because it does not consider the entire grid.

### Challenging Test Input
To expose the bug, we can create a test case where the top-left and bottom-right corners are different colors, but the grid can still be made uniform. A good example is a grid where the top-left and bottom-right corners are different, but the rest of the grid is already uniform in one color.

### Test Input
```plaintext
1
3 3
BWW
BWW
BWW
```

### Explanation
- **Grid Configuration**: The top-left corner is 'B' and the bottom-right corner is 'W'. According to the buggy code, it will immediately return "NO" because the corners are different.
- **Correct Answer**: However, the correct answer is "YES" because the entire grid can be made uniform by selecting the top-left corner 'B' and any other 'B' in the grid, and then using the operation to fill the entire grid with 'W'.

This test input should expose the bug in the initial check and boundary check logic of the buggy code.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
    public static void main(String[] args) throws IOException {
//        BinarySearchStep2_C solution = new BinarySearchStep2_C();
//        solution.solution();

//        CF80_D2_A solution = new CF80_D2_A();
//        solution.solution();

//        CF196_D2_A sol = new CF196_D2_A();
//        sol.solution();

//        CF39_D2_A sol = new CF39_D2_A();
//        sol.solution();

//        CF157_D1_A sol = new CF157_D1_A();
//        sol.solution();

//        CF969_D2_A sol = new CF969_D2_A();
//        sol.solution();

//        CF157_D1_B sol = new CF157_D1_B();
//        sol.solution();

//        Test sol = new Test();
//        sol.solution();

//        CF676_D2_A sol = new CF676_D2_A();
//        sol.solution();

//        CodeChef_NXS2 sol = new CodeChef_NXS2();
//        sol.solution();

//        DijkstraNSquared sol = new DijkstraNSquared();
//        sol.solution();

//        DijkstraNLogN sol = new DijkstraNLogN();
//        sol.solution();

//        SPOJ_Highways sol = new SPOJ_Highways();
//        sol.solution();

//        CFAlphaRound20_C sol =new CFAlphaRound20_C();
//        sol.solution();

//        CF941_D2_A sol = new CF941_D2_A();
//        sol.solution();

//        CF941_D2_B sol = new CF941_D2_B();
//        sol.solution();

        Scanner sc =new Scanner(System.in);
        int t=  sc.nextInt();
        while(t-- != 0){
            int n = sc.nextInt();
            int m = sc.nextInt();
            char[][] arr= new char[n][m];
            sc.nextLine();
            for(int i = 0 ;  i< n ; i ++){
                String str = sc.nextLine();
                arr[i] = str.toCharArray();
            }

            boolean atLeft = false;
            boolean atRight = false;
            boolean done = false;
            for(int i = 0 ; i < n ;  i++){
                boolean atRow = false;
                if(arr[i][0] == 'B')
                    atLeft = true;
                if(arr[i][m-1] == 'B')
                    atRight = true;
                for(int j = 0  ; j < m ; j ++){
                    if (arr[i][j] == 'B') {
                        atRow = true;
                        break;
                    }
                }
                if(!atRow){
                    break;
                }
                if(i == n-1){
                    if(atLeft && atRight && atRow){
                        done = true;
                        System.out.println("YES");
                    }
                }
            }
            if(done)
                continue;
            atRight = false;
            atLeft = false;
            for(int i = 0 ; i < n ;  i++){
                boolean atRow = false;
                if(arr[i][0] == 'W')
                    atLeft = true;
                if(arr[i][m-1] == 'W')
                    atRight= true;
                for(int j = 0  ; j < m ; j ++){
                    if(arr[i][j] == 'W') {
                        atRow = true;
                        break;
                    }
                }
                if(!atRow){
                    System.out.println("NO");
                    break;
                }
                if(i == n-1){
                    if(atLeft && atRight && atRow){
                        System.out.println("YES");
                    } else {
                        System.out.println("NO");
                    }
                }
            }

        }

    }
}

class FastReader1 {
    BufferedReader br;
    StringTokenizer st;

    public FastReader1()
    {
        br = new BufferedReader(
                new InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() { return Integer.parseInt(next()); }

    long nextLong() { return Long.parseLong(next()); }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try {
            if(st.hasMoreTokens()){
                str = st.nextToken("\n");
            }
            else{
                str = br.readLine();
            }
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}

**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 provided buggy code, we need to consider the logic and potential flaws in the implementation. The buggy code seems to check if the grid can be made all black ('B') or all white ('W') by examining the presence of 'B' or 'W' at the edges and within the rows. However, it does not correctly handle cases where the grid can be transformed but does not meet the specific edge conditions.

### Steps to Generate the Test Input:
1. **Identify the Bug**: The bug lies in the fact that the code only checks if the grid can be made all black or all white by examining the edges and rows. It does not consider the possibility of transforming the grid through operations that do not necessarily involve the edges.

2. **Construct a Counter-Example**: We need a grid that can be made all one color but does not meet the edge conditions checked in the buggy code.

3. **Small-Scale Test Input**: Ensure the test input is small enough to fit within the constraints and is complete and valid.

### Challenging Test Input:
Consider a 3x3 grid that can be made all white but does not have 'W' at the edges or in every row.

```plaintext
1
3 3
BWB
WBW
BWB
```

### Explanation:
- **Grid Description**: The grid is a 3x3 matrix with the following initial configuration:
  ```
  BWB
  WBW
  BWB
  ```
- **Transformation**: This grid can be made all white by selecting the following positions:
  - Select (1, 1) and (3, 3) to color the entire grid white.
- **Edge Condition**: The grid does not have 'W' at the edges or in every row, which the buggy code might incorrectly identify as "NO".

This test input should expose the bug in the buggy code, as it will not correctly identify that the grid can be made all white.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class type1>
#define ll long long int
#define endl "\n"
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using ordered_multiset = tree <type1, null_type, less_equal <type1>, rb_tree_tag, tree_order_statistics_node_update>;
 //ordered_multiset <ll> kek;(declaration for multiorder set)
// ordered_set o_set;(declaration)
//kek.order_of_key(i);(strictly less then i for multi order set)
//o_set.order_of_key(5) ;(strictly less then i for multi order set)
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define mod 1000000007
ll POW(ll a,ll b)
{   ll ans=1;
   while(b>0)
   {   if(b%2)ans=(ans*a)%mod;
       b/=2;
       a=(a*a)%mod;
   }
   return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

     ll t;
     cin>>t;

     while(t--)
     {
          ll n,m,i,j;
          cin>>n>>m;
         char arr[n][m];
         ll ans=0;
          for(i=0;i<n;i++)
          {
            for(j=0;j<m;j++)
            {
                  cin>>arr[i][j];
            }
          }
          if(arr[0][0]==arr[0][m-1]&&arr[0][0]==arr[n-1][0]&&arr[0][0]==arr[n-1][m-1])
          {
              cout<<"YES\n";
              continue;
          }
          if(arr[0][0]==arr[n-1][m-1])
          {
             yes;
             continue;
          }
          if(arr[n-1][0]==arr[0][m-1])
          {
             yes;
             continue;
          }
       ans=0;
       ll f1=0;
       ll f2=0;
       if(arr[0][0]=='W')
       {
           f1=1;
           f2=1;
       }
       for(i=1;i<m;i++)
       {
          if(arr[0][i]=='W')f1=1;

       }
       for(i=1;i<n-1;i++)
       {
          if(arr[i][0]=='W')f2=1;

       }
       ll f3=0;
       ll f4=0;
       if(arr[n-1][m-1]=='W')
       {
           f3=1;
           f4=1;
       }
       for(i=0;i<m-1;i++)
       {
          if(arr[n-1][i]=='W')f3=1;
       }
       for(i=0;i<n-1;i++)
       {
          if(arr[i][m-1]=='W')f4=1;
       }
       if(f1&&f2&&f3&&f4)
       {
          ans=1;
       }

               f1=0;
       f2=0;
       if(arr[0][0]=='B')
       {
           f1=1;
           f2=1;
       }
       for(i=1;i<m;i++)
       {
          if(arr[0][i]=='B')f1=1;

       }
       for(i=1;i<n-1;i++)
       {
          if(arr[i][0]=='B')f2=1;

       }
        f3=0;
       f4=0;
       if(arr[n-1][m-1]=='B')
       {
           f3=1;
           f4=1;
       }
       for(i=0;i<m-1;i++)
       {
          if(arr[n-1][i]=='B')f3=1;
       }
       for(i=0;i<n-1;i++)
       {
          if(arr[i][m-1]=='B')f4=1;
       }
       if(f1&&f2&&f3&&f4)
       {
          ans=1;
       }

      if(ans)yes;
      else
          no;
     }

    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
2
2 2
WB
BW
4 4
WBWB
BWBW
WBWB
BWBW
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
using ll = long long;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    bool ans = true;
    int blackTop = 0, whiteTop = 0, blackBottom = 0, whiteBottom = 0;
    for (int i = 0; i < m; i++) {
        if (a[0][i] == 'B') blackTop++;
        if (a[0][i] == 'W') whiteTop++;
        if (a[n - 1][i] == 'B') blackBottom++;
        if (a[n - 1][i] == 'W') whiteBottom++;
    }
    if ((blackTop == m && whiteBottom == m) || (whiteTop == m && blackBottom == m)) {
        ans = false;
    }
    int blackLeft = 0, whiteLeft = 0, blackRight = 0, whiteRight = 0;
    for (int i = 0; i < n; i++) {
        if (a[i][0] == 'B') blackLeft++;
        if (a[i][0] == 'W') whiteLeft++;
        if (a[i][m - 1] == 'B') blackRight++;
        if (a[i][m - 1] == 'W') whiteRight++;
    }
    if ((blackLeft == n && whiteRight == n) || (whiteLeft == n && blackRight == n)) {
        ans = false;
    }
    if ((n == 1 && m > 1) || (n > 1 && m == 1)) {
        ans = false;
    }
    cout << (ans ? "YES\n" : "NO\n");
}

int main() {
    ios::sync_with_stdio(false); cin.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 expose the bug in the provided code, we need to focus on edge cases where the code's logic might fail. The code checks the top, bottom, left, and right edges of the grid and makes decisions based on the colors of these edges. However, it does not consider the entire grid, which can lead to incorrect outputs.

### Steps to Generate the Test Input:
1. **Identify the Bug**: The bug is in the logic that only checks the edges of the grid. It fails to consider the possibility of internal configurations that could still allow the grid to be filled with a single color.
2. **Create a Test Case**:
   - A grid where the edges are all one color but the interior is another color.
   - A grid where the edges are not uniform but the interior can still be filled to a single color.

### Example Test Input:
```plaintext
2
3 3
BBB
BWB
BBB
4 4
BBWW
BWWW
WWWW
WWWW
```

### Explanation:
1. **First Test Case**:
   - Grid:
     ```
     BBB
     BWB
     BBB
     ```
   - The edges are all 'B', but the interior contains a 'W'. The code will incorrectly output "NO" because it only checks the edges. However, it is possible to fill the entire grid with 'B' by selecting the corners and filling the middle.

2. **Second Test Case**:
   - Grid:
     ```
     BBWW
     BWWW
     WWWW
     WWWW
     ```
   - The top-left corner is 'B', and the rest of the grid is 'W'. The code will incorrectly output "NO" because it only checks the edges. However, it is possible to fill the entire grid with 'W' by selecting the top-right and bottom-right corners and filling the interior.

### Output:
```plaintext
2
3 3
BBB
BWB
BBB
4 4
BBWW
BWWW
WWWW
WWWW
```

2
3 3
BBB
BWB
BBB
4 4
BBWW
BWWW
WWWW
WWWW


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
def solve():
    n, m = map(int, input().split())
    mat = []

    for _ in range(n):
        r = input().strip()
        mat.append([i for i in r])

    c = list(map(list, zip(*mat)))
    w = b = 0

    for r in mat:
        if 'W' in r:
            w += 1
        if 'B' in r:
            b += 1

    for d in c:
        if 'W' in d:
            w += 1
        if 'B' in d:
            b += 1

    if w==n+m or b==n+m:
        return "YES"
    return "NO"

for _ in range(int(input())):
    print(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
3
2 2
BW
WB
3 3
BBW
BBB
BBW
4 4
BWBW
WBWB
BWBW
WBWB
```

3
2 2
BW
WB
3 3
BBW
BBB
BBW
4 4
BWBW
WBWB
BWBW
WBWB


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Rectangle Filling
time_limit_ms: 1000
memory_limit_mb: 256
Description: There is an $$$n \times m$$$ grid of white and black squares. In one operation, you can select any two squares of the same color, and color all squares in the subrectangle between them that color.

Formally, if you select positions $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, both of which are currently the same color $$$c$$$, set the color of all $$$(x, y)$$$ where $$$\min(x_1, x_2) \le x \le \max(x_1, x_2)$$$ and $$$\min(y_1, y_2) \le y \le \max(y_1, y_2)$$$ to $$$c$$$.

This diagram shows a sequence of two possible operations on a grid:

Is it possible for all squares in the grid to be the same color, after performing any number of operations (possibly zero)?

Input: The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 500$$$) — the number of rows and columns in the grid, respectively.

Each of the next $$$n$$$ lines contains $$$m$$$ characters 'W' and 'B' — the initial colors of the squares of the grid.

It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$3\cdot 10^5$$$.

Output: For each test case, print "YES" if it is possible to make all squares in the grid the same color, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Examples:
input:
8
2 1
W
B
6 6
WWWWBW
WBWWWW
BBBWWW
BWWWBB
WWBWBB
BBBWBW
1 1
W
2 2
BB
BB
3 4
BWBW
WBWB
BWBW
4 2
BB
BB
WW
WW
4 4
WWBW
BBWB
WWBB
BBBB
1 5
WBBWB
output:
NO
YES
YES
YES
YES
NO
YES
NO

Note: In the first example, it is impossible to ever change the color of any square with an operation, so we output NO.

The second example is the case pictured above. As shown in that diagram, it is possible for all squares to be white after two operations, so we output YES.

In the third and fourth examples, all squares are already the same color, so we output YES.

In the fifth example we can do everything in two operations. First, select positions $$$(2, 1)$$$ and $$$(1, 4)$$$ and color all squares with $$$1 \le x \le 2$$$ and $$$1 \le y \le 4$$$ to white. Then, select positions $$$(2, 1)$$$ and $$$(3, 4)$$$ and color all squares with $$$2 \le x \le 3$$$ and $$$1 \le y \le 4$$$ to white. After these two operations all squares are white.

Buggy Code:
"""
if the first row and the last rows are the same then it is only possible if both have the same color
"""

t = int(input())

for _ in range(t):

    matrix = []
    n, m = map(int, input().split())

    for _ in range(n):
        matrix.append(input())

    ans = "YES"
    impossible = True
    for i in range(m - 1):
        if (matrix[0][i] != matrix[0][i + 1]) or (
            matrix[n - 1][i] != matrix[n - 1][i + 1]
        ):
            impossible = False

    if impossible and (matrix[0][0] != matrix[n - 1][0]):
        ans = "NO"

    impossible = True

    for i in range(n - 1):
        if (matrix[i][0] != matrix[i + 1][0]) or (
            matrix[i][m - 1] != matrix[i + 1][m - 1]
        ):
            impossible = False

    if impossible and (matrix[0][m - 1] != matrix[0][m - 1]):
        ans = "NO"

    if n == 1 and (matrix[0][0] != matrix[0][m - 1]):
        ans = "NO"

    if m == 1 and (matrix[0][0] != matrix[n - 1][0]):
        ans = "NO"

    print(ans)

**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
BW
WB
3 3
BBW
BWW
BBB
4 4
BWBW
WBWB
BWBW
WBWB
```

3
2 2
BW
WB
3 3
BBW
BWW
BBB
4 4
BWBW
WBWB
BWBW
WBWB