Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with *n* vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."

Same with some writers, she wants to make an example with some certain output: for example, her birthday or the number of her boyfriend. Can you help her to make a test case with answer equal exactly to *k*?
The first line contains a single integer *k* (1 ≤ *k* ≤ 10<sup class="upper-index">9</sup>).
def max_multiply(n):
    if n <= 3:
        return n - 1
    quotient, remainder = n // 3, n % 3
    if remainder == 0:
        return 3 ** quotient
    elif remainder == 1:
        return 3 ** (quotient - 1) * 4
    else:
        return 3 ** quotient * 2

def bs(l, r, k):
    while l <= r:
        m = (l + r) // 2
        if(max_multiply(m) >= k): r = m - 1
        else: l = m + 1
    return l

def self_solve():
    k = int(input())
    m = 0
    if k == 1:
        print("NY")
        print("YN")
    elif k == 2:
        print("NNYY")
        print("NNYY")
        print("YYNN")
        print("YYNN")
    elif k == 3:
        print("NNYYY")
        print("NNYYY")
        print("YYNNN")
        print("YYNNN")
        print("YYNNN")
    else:
        l, r = 0, 998
        m = bs(l, r, k)
        flag = m % 3
        if not flag: flag += 3
        m += 2
        ret = [['N'] * m for _ in range(m)]
        cnt = 0
        for i in range(2, 5):
            t = i
            while t < m:
                for j in range(5 - i, 8 - i):
                    index = t + j
                    if index < m:
                        ret[t][index] = 'Y'
                        ret[index][t] = 'Y'
                        if m - index <= flag:
                            cnt += 1
                            if cnt == k:
                                break 
                t += 3
            
        ret[0][2] = ret[0][3] = ret[0][4] = 'Y'
        ret[2][0] = ret[3][0] = ret[4][0] = 'Y'
        t = (m - 2) % 3
        if t == 0:
            t += 3
        for i in range(1, t + 1):
            ret[-i][1] = ret[1][-i] = 'Y'
        print(m)
        for i in range(m):
            for j in range(m):
                print(ret[i][j], end = "")
            print()

self_solve()
