const isEven = (n: number) => n % 2 == 0; const writeRow = (n: number, o: string, t: string) => { let result = o; for (let i = 0; i < n; i++) { if (isEven(i)) result += t; if (!isEven(i)) result += o; } return result } const Main = (input) => { const data = input.split("\n") const width: number = data[0], heigh: number = data[1]; const start: string = data[2]; const second: string = start === 'W' ? 'B' : 'W'; let result = ''; for (var i = 1; i <= heigh; i++) { if (!isEven(i)) result += writeRow(width, start, second); if (isEven(i)) result += writeRow(width, second, start); if (i < heigh) result += `\n` } console.log(result); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));