#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_skip() while(*rp++>=48) #define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} char*mmap(); char wbuf[1<<25]; #define A "0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 " char const a011[]=A A A A A A A; #undef A #define A "1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 " char const a122[]=A A A A A A A; #undef A int main(){ char*rp=mmap(0l,1l<<25,1,2,0,0ll); char*wp=wbuf; rd_skip(); while(*rp){ rd(h); rd(w); long hoff=h%3==2; long woff=w%3==2; char const * x011=a011+2*woff; char const * x122=a122+2*woff; long xlen=w*2; for(long y=h+hoff;--y>=hoff;){ memcpy(wp,y%3?x122:x011,xlen); wp+=xlen; } } write(1,wbuf,wp-wbuf); _exit(0); }