#P13974. [VKOSHP 2024] Petya's Cryptography

[VKOSHP 2024] Petya's Cryptography

题目描述

Petya received a failing grade in cryptography, but it was the teachers who did not understand his genius, not him being lazy. To convince the entire world community of his genius, Petya created a new public key encryption system --- PSA\textit{PSA}. Any self-respecting public key cryptosystem has a public key and a private key.

As a private key, Petya chose a tree TT, and as a public key --- two numbers (n,p)(n, p), where nn is the number of vertices in the tree TT, and pp is the number of paths of length 2 in TT. Recall that a tree is an undirected connected graph that does not contain cycles.

The peculiarity of Petya's cryptosystem is that any private key corresponding to the public key will suffice to break it. But that's not a problem; Petya chose quite a complex task, right? Restore any private key of the cryptosystem PSAPSA or state that such a public key could not have been produced.

输入格式

The input consists of a single line containing two numbers nn and pp (1n10001 \leq n \leq 1000, 0p1090 \leq p \leq 10^9).

输出格式

If a solution exists, output Yes\texttt{Yes} in the first line. In the next n1n - 1 lines, output two distinct integers from 1 to nn --- the edges of the tree.

If no solution exists, output No\texttt{No} in a single line.

7 11
Yes
1 2
2 3
3 4
3 5
3 6
3 7
5 5
No