read while read h w do for((y=h;y;--y)){ eval echo '$[('{1..$w}'%3!=w%3<2)+(y%3!=h%3<2)]' } done