{"trustable":true,"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\u003eAlice最近迷上了一个叫Sirtet的游戏。\u003c/p\u003e\u003cp\u003e在Sirtet中,玩家会得到一个$$$n \\times m$$$的网格。最初有$$$a_{i,j}$$$个方块堆叠在单元格$$$(i,j)$$$中。如果两个单元格共享边,则它们被称为相邻。玩家可以执行以下操作:\u003c/p\u003e\u003cul\u003e \u003cli\u003e 在两个\u003cspan class\u003d\"tex-font-style-bf\"\u003e相邻\u003c/span\u003e的单元格中堆叠一个方块; \u003c/li\u003e\u003cli\u003e 在一个单元格中堆叠两个方块。 \u003c/li\u003e\u003c/ul\u003e\u003cp\u003e上述的方块在高度上是相同的。\u003c/p\u003e\u003cp\u003e这是游戏的示意图。右侧状态是通过在左侧状态进行上述操作得到的,并且灰色方块是由该操作添加的。\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/718947fee7939e7ba8ca4b91b1913063?v\u003d1700056565\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e\u003cp\u003e玩家的目标是使用上述操作使所有单元格的高度相同(即每个单元格中都有相同数量的方块)。\u003c/p\u003e\u003cp\u003e然而,Alice发现在某些初始网格上,无论她使用什么策略都无法达到目标。因此,她想知道初始网格的数量,满足以下条件:\u003c/p\u003e\u003cul\u003e \u003cli\u003e 对于所有的$$$1 \\le i \\le n$$$和$$$1 \\le j \\le m$$$,$$$L \\le a_{i,j} \\le R$$$; \u003c/li\u003e\u003cli\u003e 玩家可以使用上述操作达到目标。 \u003c/li\u003e\u003c/ul\u003e\u003cp\u003e请帮助Alice解决这个问题。请注意,答案可能很大,请输出所需值模$$$998,244,353$$$。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e仅一行包含四个整数$$$n$$$、$$$m$$$、$$$L$$$和$$$R$$$($$$1\\le n,m,L,R \\le 10^9$$$、$$$L \\le R$$$、$$$n \\cdot m \\ge 2$$$)。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e输出一个整数,表示所需答案模$$$998,244,353$$$。\u003c/p\u003e"}},{"title":"示例 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\u003e2 2 1 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"示例 2","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 2 1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e在第一个示例中,满足要求的唯一初始网格是$$$a_{1,1}\u003da_{2,1}\u003da_{1,2}\u003da_{2,2}\u003d1$$$。因此答案应为$$$1$$$。\u003c/p\u003e\u003cp\u003e在第二个示例中,满足要求的初始网格是$$$a_{1,1}\u003da_{1,2}\u003d1$$$和$$$a_{1,1}\u003da_{1,2}\u003d2$$$。因此答案应为$$$2$$$。\u003c/p\u003e"}}]}