object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  show
  def show = {
    val (n, pair) = (2 to 40).map { whole ⇒ (whole, maxPairCount(whole)) }.maxBy { it ⇒ estimated(it._2, it._1 - it._2) }
    println(n)

    for (from ← 0 until n) {
      if (from < pair) {
        println((0 until n).map { to ⇒
          if (to < pair) 'N'
          else 'Y'
        }.mkString)
      } else {
        println((0 until n).map { to ⇒
          if (from == to) 'N'
          else 'Y'
        }.mkString)
      }
    }
  }

  def estimated(pair: Int, nonPair: Int): Double = {
    pair - pair.toDouble / (nonPair + 1) - nonPair.toDouble / (pair + nonPair)
  }
  def maxPairCount(wholeNode: Int): Int = {
    (1 until wholeNode).maxBy{pair ⇒ estimated(pair, wholeNode - pair)}
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
