{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"### Read problems statements in [Mandarin Chinese](https://www.codechef.com/download/translated/COOK128/mandarin/TDISTS.pdf), [Russian](https://www.codechef.com/download/translated/COOK128/russian/TDISTS.pdf), and [Bengali](https://www.codechef.com/download/translated/COOK128/bengali/TDISTS.pdf) as well.\r\n\r\nA tree is defined as a connected, undirected graph with $n$ vertices and $n−1$ edges. The distance between two vertices in a tree is equal to the number of edges on the unique simple path between them.\r\n\r\nYou are given two integers $x$ and $y$. Construct a tree with the following properties:\r\n- The number of pairs of vertices with an **even** distance between them equals $x$.\r\n- The number of pairs of vertices with an **odd** distance between them equals $y$.\r\n\r\nBy a pair of vertices, we mean an ordered pair of two (possibly, the same or different) vertices.\r\n\r\n### Input\r\nThe first line of the input contains a single integer $T$ denoting the number of test cases. Each test case consists of one line containing two space-separated integers $x$ and $y$.\r\n\r\n### Output\r\nFor each test case, if there is no tree satisfying the given properties, print ``\"NO\"`` (without quotes).\r\n\r\nOtherwise, on the first line print ``\"YES\"`` (without quotes). Then print integer $n$ denoting the number of vertices in the tree, followed by $n−1$ lines describing the edges of the tree in any order. Vertices are numbered from $1$ to $n$. If there are multiple answers, print any of them.\r\n\r\n### Constraints\r\n- $1 \\leq T \\leq 100$\r\n- $1 \\leq x,y \\leq 10^9$\r\n- $x + y \\leq 10^9$\r\n\r\n### Example Input\r\n```\r\n4\r\n2 2\r\n29 20\r\n3 12\r\n6 3\r\n```\r\n\r\n### Example Output\r\n```\r\nYES\r\n2\r\n1 2\r\nYES\r\n7\r\n1 2\r\n1 3\r\n2 4\r\n2 5\r\n3 6\r\n3 7\r\nNO\r\nNO\r\n```\r\n\r\n### Explanation\r\nIn the first test case, the pairs $(1 ,1)$ and $(2 ,2)$ have an even distance, while the pairs $(1 ,2)$ and $(2 ,1)$ have an odd distance."}}]}