Under construction

Still being built. Things may change

Tree Planting

Time limit2sMemory limit1024 MB

Summary
Decide if a connected set of grid cells exists with A cells of even neighbor count and B of odd, and print one layout.
Level

Medium6 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

Seunghyeon wants to plant trees. To do so, Seunghyeon picks some cells on an infinite grid and scatters tree seeds on them. The seeds have a mysterious power. Under the influence of nearby seeds, each seed grows into either an apple tree or a peach tree.

Two seeds are called adjacent if they sit in cells that share an edge. A seed with an even number of adjacent seeds becomes an apple tree. A seed with an odd number of adjacent seeds becomes a peach tree.

Seeds in two cells that share an edge are adjacent

Suppose Seunghyeon plants 5 seeds as shown above. The blue arrows mark the adjacent seeds. The middle seed has 3 adjacent seeds, so it becomes a peach tree.

Three apple trees and two peach trees

In this case, 3 apple trees and 2 peach trees grow.

All seeds must be connected on the grid. That is, for any two seeds, you must be able to travel between them using only adjacent seeds. For example, the layout below is impossible.

A layout where the seeds are not all connected

Seunghyeon wants to plant AA apple trees and BB peach trees. Determine whether this is possible, and if it is, print a layout of the trees.

Input

The first line contains non-negative integers AA and BB, separated by a space. (A≥0A \ge 0; B≥0B \ge 0; 1≤A+B≤2001 \le A + B \le 200)

Output

On the first line, print YES if the layout is possible, and NO otherwise.

If the layout is possible, print RR and CC, the number of rows and columns, separated by a space on the second line. (1≤R,C≤2001 \le R, C \le 200)

On the following RR lines, print CC characters per line with no spaces. Each character is O or .. Print O where a seed is planted and . where there is none.

Examples5

  1. Example 1

    Input
    3 2
    
    Expected output
    YES
    3 3
    .OO
    OOO
    ...
    
  2. Example 2

    Input
    1 0
    
    Expected output
    YES
    1 1
    O
    
  3. Example 3

    Input
    7 0
    
    Expected output
    YES
    3 3
    .OO
    OOO
    OO.
    
  4. Example 4

    Input
    8 0
    
    Expected output
    YES
    4 4
    ....
    .OOO
    .O.O
    .OOO
    
  5. Example 5

    Input
    9 0
    
    Expected output
    NO