/* -*- coding: utf-8 -*- * * 1851.cc: No.1851 Regular Tiling - yukicoder */ #include #include using namespace std; /* constant */ /* typedef */ /* global variables */ inline int cell(int y, int x) { return (y % 3 > 0 ? 1 : 0) + (x % 3 > 0 ? 1 : 0); } /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int h, w; scanf("%d%d", &h, &w); int y0 = (h % 3 == 2) ? 1 : 0; int x0 = (w % 3 == 2) ? 1 : 0; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) printf("%d%c", cell(y + y0, x + x0), (x + 1 < w) ? ' ' : '\n'); } return 0; }