//
// Road2Master.cpp
// Road2Master
//
// Created by Rakhman Abdirashov on 12/14/19.
// Copyright © 2019 Rakhman Abdirashov. All rights reserved.
//
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer {cout << "NO"; exit(0);}
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)
const long long MXN = 1e5 + 10;
const long long MNN = 1e4 + 520;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9;
typedef long long llong;
typedef unsigned long long ullong;
using namespace std;
int n, m;
bool ans[1010][1010];
int cnt[1010];
void output(int n, int m){
int sum = 0;
if(n >= m){
sum = n;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
ans[i][j] = 1;
}
cnt[i] = m;
}
for(int i = 1; i <= m; i++){
int lol = n / 2 + 1;
for(int j = 1; j <= n; j++){
if(lol == 0) break;
if(cnt[j] > m / 2 + 1){
ans[j][i] = 0;
cnt[j]--;
lol--;
}
}
if(lol != 0) break;
else sum++;
}
}else{
sum = m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
ans[i][j] = 0;
cnt[j] = n;
}
}
int lol = m / 2 + 1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(lol == 0) break;
if(cnt[j] > n / 2 + 1){
cnt[j]--;
ans[i][j] = 1;
lol--;
}
}
if(lol == 0) sum++;
else break;
}
}
cout << sum << nl;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cout << (ans[i][j] == 1 ? '+' : '-');
}
cout << nl;
}
}
int main(){
int t;
cin >> t;
while(t--){
cin >> n >> m;
output(n, m);
}
}
/*
1 2 3 4 5 6
2 3 4 1 5 6
4 1 5 2 3 6
4 5
+++--
+++--
+++--
+++--
4 6
--++++
--
------
------
4 + 2
+++++
+++++
-----
-----
-----
5 + 2
7
-+-++
-+-++
-+-++
--+++
+--++
+-+++
+-+++
4 + 2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
in the table A+B is not equal to 7 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
in the table A+B is not equal to 48 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
in the table A+B is not equal to 7 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
1548 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
1640 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
in the table A+B is not equal to 7 |