#include #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ int testcase_i; scanf("%d", &testcase_i); for (int ___ = 0; ___ < testcase_i; ___++){ int H, W; scanf("%d %d", &H, &W); char pattern[3][3]; if(H%3 == 1){ if(W%3 == 1){ char tmp[3][3] = {{'0','1','1'},{'1','2','2'},{'1','2','2'}}; rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j]; }else{ char tmp[3][3] = {{'1','1','0'},{'2','2','1'},{'2','2','1'}}; rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j]; } }else if(W%3 == 1){ char tmp[3][3] = {{'1','2','2'},{'1','2','2'},{'0','1','1'}}; rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j]; }else{ char tmp[3][3] = {{'2','2','1'},{'2','2','1'},{'1','1','0'}}; rep(i,3) rep(j,3) pattern[i][j] = tmp[i][j]; } for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { printf("%c", pattern[i%3][j%3]); printf(j < W-1 ? " " : "\n"); } } } }