eolymp
bolt
Try our new interface for solving problems
Problems

Graph Theory

Graph Theory

\includegraphics{https://static.e-olymp.com/content/fc/fca8e2227f63527071e0abc69e988bdb468d454c.jpg} \includegraphics{https://static.e-olymp.com/content/ec/ec680bd46355e4af82a251fef70d4b6432fd4623.jpg} Serge is studying graph theory. Recently he has learned about graph radius and diameter. Consider undirected unweighed connected graph \textbf{G}, let us denote the length of the shortest path between vertices \textbf{s} and \textbf{t} as \textbf{ρ(s, t)}. Radius \textbf{r(G)} of the graph is . Diameter \textbf{d(G)} of the graph is . Intuitively, diameter of the graph is the largest distance that you need to go to get from one vertex to another, and radius is the largest distance you can be forced to go if you choose where you would go from. The professor on the lecture proved that \textbf{d(G)/2} ≤ \textbf{r(G)} ≤ \textbf{d(G)} for any graph \textbf{G}. Now Serge wonders whether for any values \textbf{d} and \textbf{r} such that \textbf{d/2} ≤ \textbf{r} ≤ \textbf{d} there exists graph \textbf{G} such that \textbf{d(G) = d} and \textbf{r(G) = r}. Help him to find that out. \InputFile The input file contains two integer numbers \textbf{d} and \textbf{r} (\textbf{d/2} ≤ \textbf{r} ≤ \textbf{d} ≤ \textbf{50}, \textbf{1} ≤ \textbf{r}). \OutputFile If there exists a graph with the given diameter and radius, output "\textbf{YES}" at the first line of the output file. The second line must contain two integer numbers: \textbf{n} (\textbf{2} ≤ \textbf{n} ≤ \textbf{400}) and \textbf{m} - the number of vertices and the number of edges. The following \textbf{m} lines must contain two integer numbers each - the vertices connected by the corresponding edge. There must be no loops and no parallel edges. If there is no such graph, output "\textbf{NO}" at the first line of the output file.
Time limit 1 second
Memory limit 256 MiB
Input example #1
1 1
Output example #1
YES
2 1
1 2
Author Andrew Stankevich
Source Andrew Stankevich Contest 32, Petrozavodsk Summer Training Camp, Wednesday, September 3, 2008