시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB23161571.429%

문제

Given are integers $s$, $t$, and $u$.

Let $a$, $b$, and $c$ be distinct complex numbers that satisfy the following conditions:

  • $a+b+c=s$,
  • $ab + bc + ca=t$,
  • $abc=u$.

It is guaranteed that such $a$, $b$, and $c$ exist for the given $s$, $t$, and $u$.

Given positive integers $n$ and $m$, calculate the ratio

$$ \frac{a^n(b^m-c^m)+b^n(c^m-a^m)+c^n(a^m-b^m)}{(a-b)(b-c)(c-a)} $$

modulo $998\,244\,353$.

입력

The first line of input contains two integers $n$ and $m$ ($1 \le n, m \le 10^{18}$).

The second line contains three integers $s$, $t$ and $u$ ($0 \le s, t, u < 998\,244\,353$).

It is guaranteed that the distinct complex numbers $a$, $b$, and $c$ from the statement exist for the given $s$, $t$, and $u$.

출력

It can be shown that the answer can be represented as a rational number $p/q$ where $p$ and $q$ are integers, $(p,q)=1$, $q>0$ and $q$ is not divisible by $998\,244\,353$.

예제 입력 1

2 3
314 159 265

예제 출력 1

159

예제 입력 2

1000000000000000000 800000000000000000
6 11 6

예제 출력 2

76083766

예제 입력 3

1000000000000000000 500000000000000000
505459328 165146837 982639180

예제 출력 3

228155372