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