{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eA labelled forest with $$$n$$$ vertices is an acyclic undirected simple graph in which vertices are labelled by $$$1, 2, \\cdots, n$$$. Two labelled forests are regarded as different if their numbers of vertices are different or, if they have the same number of vertices, for some integers $$$i$$$ and for vertices labelled by $$$i$$$ in these two forests, their neighbours have different labels (which means that the sets of labels corresponding to all neighbours of vertices labelled by $$$i$$$ in these two forests are different).\u003c/p\u003e\n\u003cp\u003egzs wants to randomly choose a labelled forest $$$G$$$ from all possible labelled forests having $$$n$$$ vertices with equal probability. Then, he will set $$$\\delta(i, j)$$$ to the number of edges on the shortest path from the vertex labelled $$$i$$$ to the vertex labelled $$$j$$$ if the shortest path exists, or set $$$\\delta(i, j)$$$ to $$$m$$$ otherwise. Calculate the expected value of\u003c/p\u003e\n\u003cp\u003e$$$$$$\\sum_{i \u003d 1}^{n}{\\sum_{j \u003d i + 1}^{n}{\\delta^2(i, j)}},$$$$$$\u003c/p\u003e\n\u003cp\u003e modulo $$$998244353$$$. \u003c/p\u003e\n\u003cp\u003eMore precisely, if the reduced fraction of the expected value is $$$\\frac{p}{q}$$$, what you should provide is the minimum non-negative integer $$$r$$$ such that $$$q r \\equiv p \\pmod{998244353}$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input contains several test cases, and the first line contains a positive integer $$$T$$$ indicating the number of test cases which is up to $$$2 \\times 10^5$$$.\u003c/p\u003e\n\u003cp\u003eFor each test case, the only one line contains two integers $$$n$$$ and $$$m$$$ where $$$1 \\leq n \\leq 2 \\times 10^5$$$ and $$$n \\leq m \\leq 998244352$$$.\u003c/p\u003e\n\u003cp\u003eWe guarantee that the modular multiplicative inverse of $$$q$$$ in each test case always exists, in other words, the condition $$$q \\not \\equiv 0 \\pmod{998244353}$$$ is guaranteed to be true in all test cases.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, output a line containing the answer modulo $$$998244353$$$.\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n1 1\n2 3\n3 7\n4 16\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n5\n66\n576\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}