{"problem":{"name":"± ab","description":{"content":"You are given an integer sequence $A=(A_1,A_2,\\ldots,A_N)$. Also, you are given positive integers $a,b,s,t$. It is guaranteed that $a$ and $b$ are **coprime**. You can perform the following four types","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":10000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc210_f"},"statements":[{"statement_type":"Markdown","content":"You are given an integer sequence $A=(A_1,A_2,\\ldots,A_N)$. Also, you are given positive integers $a,b,s,t$. It is guaranteed that $a$ and $b$ are **coprime**.\nYou can perform the following four types of operations on $A$:\n\n*   Choose an integer $i$ satisfying $1\\leq i\\leq N$ and add $a$ to $A_i$. This operation costs $s$.\n*   Choose an integer $i$ satisfying $1\\leq i\\leq N$ and subtract $a$ from $A_i$. This operation costs $s$.\n*   Choose an integer $i$ satisfying $1\\leq i\\leq N$ and add $b$ to $A_i$. This operation costs $t$.\n*   Choose an integer $i$ satisfying $1\\leq i\\leq N$ and subtract $b$ from $A_i$. This operation costs $t$.\n\nAnswer $Q$ queries. In the $q$\\-th query, you are given an integer $B_q$, so find the following value modulo $998244353$:\n\n*   The minimum total cost required to make $A_{1}=A_{2}=\\cdots=A_{N}=B_q$ hold. It can be proved that it is possible to make $A_{1}=A_{2}=\\cdots=A_{N}=B_q$ hold.\n\n## Constraints\n\n*   $1\\leq N\\leq 2\\times 10^5$\n*   $1\\leq Q\\leq 2\\times 10^5$\n*   $1\\leq a,b,s,t\\leq 5\\times 10^8$\n*   $a$ and $b$ are coprime.\n*   $1\\leq A_i\\leq 5\\times 10^8$\n*   $1\\leq B_q\\leq 5\\times 10^8$\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $Q$\n$a$ $b$ $s$ $t$\n$A_1$ $A_2$ $\\ldots$ $A_N$\n$B_1$ $B_2$ $\\ldots$ $B_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc210_f","tags":[],"sample_group":[["1 5\n3 5 4 3\n3\n1 2 3 4 5","7 11 0 11 7\n\n*   By performing operations $+a$, $-b$ on $A_1$ in order, we can make $A=(1)$. The total cost is $4+3=7$.\n*   By performing operations $-a$, $-a$, $+b$ on $A_1$ in order, we can make $A=(2)$. The total cost is $4+4+3=11$.\n*   $A=(3)$ from the beginning. The total cost is $0$.\n*   By performing operations $+a$, $+a$, $-b$ on $A_1$ in order, we can make $A=(4)$. The total cost is $4+4+3=11$.\n*   By performing operations $-a$, $+b$ on $A_1$ in order, we can make $A=(5)$. The total cost is $4+3=7$."],["3 1\n3 5 4 3\n1 2 3\n4","22\n\n*   By performing operations $+a$ on $A_1$, $+b$, $-a$ on $A_2$, and $+a,+a,-b$ on $A_3$ in order, we can make $A=(4,4,4)$. The total cost is $22$."],["5 5\n1234 4321 5 5\n1 10 100 1000 10000\n123 4567 89012345 6 789","45340 42530 531725 35135 41690"]],"created_at":"2026-03-03 11:01:14"}}