Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin >> t;
- while(t--)
- {
- int n,m;
- cin >> n >> m;
- if(n == 2 && m == 3)
- {
- cout << "BBW" << endl << "BWB" << endl;
- continue;
- }
- if(n == 2)
- {
- cout << "BB";
- bool black = true;
- for(int i=1;i<=m-2;i++)
- {
- if(black) {cout<<"B";black=false;}
- else {cout<<"W";black=true;}
- }
- black = true;
- cout << endl;
- for(int i=1;i<=m-1;i++)
- {
- if(black) {cout<<"B";black=false;}
- else {cout<<"W";black=true;}
- }
- cout << "W" << endl;
- continue;
- }
- if(m % 2 == 0)
- {
- for(int i=1;i<n;i++)
- {
- bool black = true;
- for(int j=1;j<=m;j++)
- {
- if(black) {cout<<"B";black=false;}
- else {cout<<"W";black=true;}
- }
- cout << endl;
- }
- cout << "BB";
- bool black = true;
- for(int j=1;j<=m-2;j++)
- {
- if(black) {cout<<"B";black=false;}
- else {cout<<"W";black=true;}
- }
- cout << endl;
- }
- else
- {
- for(int i=1;i<=n;i++)
- {
- bool black = true;
- for(int j=1;j<=m;j++)
- {
- if(black)
- {
- if(j==m && i>=3)
- {
- cout << "W";
- black = false;
- }
- else
- {
- cout<<"B";
- black=false;
- }
- }
- else {cout<<"W";black=true;}
- }
- cout << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement