# 入力された値を受け取る W, H, C = gets.chomp.split width = W.to_i # H行分出力する H.to_i.times do |i| if C == "B" (i + 1).odd?? str = "BW": str = "WB" puts (str * width)[0, (width - 1)] elsif C == "W" (i + 1).odd?? str = "WB": str = "BW" puts (str * width)[0, (width - 1)] end end