{"trustable":true,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003ePty loves data structures, especially segmenttree. \u003cbr\u003e\u003cbr\u003ePty thinks that the segmenttree satifies each point to represent the interval [l,r]. The point with l \u003d r is called a leaf. The other point select mid in [l,r-1] and take [l,mid] and [mid + 1,r] as son. \u003cbr\u003e\u003cbr\u003ePty gives each point in the tree a value. For the leaves, the value is 1; For the point whose right son interval size is k, the value is A; The other point’s value is B. Pty denotes the value of the tree as the value product of all points. \u003cbr\u003e\u003cbr\u003ePty denotes $f_n$ as the sum of all the tree that the interval of the root is [1,n]. He thinks that the two trees are different if and only if the shape is different. \u003cbr\u003e\u003cbr\u003eNow Pty has Q queries, for each query Pty wants to know the value of $\\sum_{i\u003dL}^R f_i^2$\u003cbr\u003e\u003cbr\u003eNoticed that the answer is large, you only need to find the answer after modulo 998244353. \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"A positive integer T in the first line indicates the number of test. \u003cbr\u003e\u003cbr\u003eFor each test,the first line contains four integers Q,k,A,B. \u003cbr\u003e\u003cbr\u003eFor the next Q lines, each line contains two intergers L,R. \u003cbr\u003e\u003cbr\u003e\u003cbr\u003e$1\\le T\\le 5, 1\\le Q \\le 5 \\times 10^4, 0 \\le A,B \u0026lt; 998244353, 1 \\le L \\le R \\le 10^7, 1 \\le k \\le 10^7$"}},{"title":"Output","value":{"format":"HTML","content":"For each query, print the answer. "}},{"title":"Sample","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\u003e1\r\n1 1 3 1\r\n4 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3249\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eThere are 5 di\u0026amp;#64256;erent trees, 1 with a value of 3,3 with a value of 9,1 with a value of 27. The sum is 3*1 + 9*3 + 27*1 \u003d 57,57*57 \u003d 3249\u003cbr\u003e"}}]}