XadillaX built two "Flandres" in his minecraft world.
You know, they were all built from wool - red wool, yellow wool, black wool, white wool, etc.
The method Hungar uses is that to make the Flandre all white! Just like the picture below:
But Devil Hungar is so stupid that he just can destroy the Flandre by doing such 3 rules below:
Turn any one block of wool.
Choose an integer H and turn the first D * H blocks from left to right and from top to bottom.
Choose an integer G and turn the first D * G blocks from right to left and from bottom to top.
(Notice that the number H, G may be different at each step)Now give you the side length of a "Flandre" and each pixel of it, you have to calculate out the minimum steps Hungar have to cost to destroy the "Flandre" so that XadillaX can get ready for the war as soon as possible.
Note: It guarantee that D divides N * N!
16 16 WBBBBBBBBBBBBRRB BPPPPPPPPPPPPRRR PPPPPPPPPPPPPRRR PPPPPPPPPPPPPPPP RPRRRPRRRPRRRPRR PPPPPBBPPPPBBPPB BBPPBYYBPPBYYBPY YYBBYYYYBBYBYYBY BYYYYBYYYYYBBYYY YYYYBYYBYYYBWBYY YYYBWBBWBYBWWWBY YYBWWWWWWBWWWWBY YYBWRWWWWWWWRWBY YYBWRWWWWWWWRWBY YYBWWWWWWWWWWWBY BYYBWWWWWWWWWBYY
40
无
XadillaX