Problem:
Max Score: $1400$ Points

Problem Statement

E869120 defined a sequence $a$ like this:

$a_1=a_2=1$, $a_{k+2}=a_{k+1}+a_k \ (k \ge 1)$

He also defined sequences $d_1, d_2, d_3, \dots , d_n$, as the following recurrence relation :

$d_{1, j} = a_j$

$d_{i, j} = \sum_{k = 1}^j d_{i - 1, k} \ (i \ge 2)$

You are given integers $n$ and $m$. Please calculate the value of $d_{n, m}$.

Since the answer can be large number, print the answer modulo $998,244,353$.

Can you solve this problem???

Input

The input is given from standard input in the following format.

$n \quad m$

Output

Print $d_{n, m}$ modulo $998,244,353$.

Constraints

$1 \le n \le 200,000$

$1 \le m \le 10^{18}$

Subtasks

Subtask 1 [ $100$ points ]

The testcase in this subtask satisfies $1 \le n, m \le 3,000$.

Subtask 2 [ $170$ points ]

The testcase in this subtask satisfies $1 \le m \le 200,000$.

Subtask 3 [ $230$ points ]

The testcase in this subtask satisfies $1 \le n \le 3$.

Subtask 4 [ $420$ points ]

The testcase in this subtask satisfies $1 \le n \le 1000$.

Subtask 5 [ $480$ points ]

There are no additional constraints.

Sample Input 1

4 7

Sample Output 1

176

The sequence is following:

$d_{i, 1}$

$d_{i, 2}$

$d_{i, 3}$

$d_{i, 4}$

$d_{i, 5}$

$d_{i, 6}$

$d_{i, 7}$

$d_1$

1

1

2

3

5

8

13

$d_2$

1

2

4

7

12

20

33

$d_3$

1

3

7

14

26

46

79

$d_4$

1

4

11

25

51

97

176

As a result, the answer is $d_{4, 7} = 176$.

Sample Input 2

12 20

Sample Output 2

174174144

Interesting number. It only contains $1$, $4$ and $7$.

Sample Input 3

16 30

Sample Output 3

102292850

You can calculate that $d_{16, 30} = 1,193,004,294,685$.

Please don't forget printing the answer mod $998,244,353$.

Writer：square1001

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	static InputStream is;
	static PrintWriter out;
	static String INPUT = "";
	
	static void solve()
	{
		int n = ni()-1;
		long m = nl();
		int mod = 998244353;
		long[] f = new long[2*n+3];
		f[0] = f[1] = 1;
		for(int i = 2;i < f.length;i++){
			f[i] = f[i-1] + f[i-2];
			if(f[i] >= mod)f[i] -= mod;
		}
		long prod = 1;
		long s = 0;
		for(int i = n-1;i >= 0;i--){
			s += f[2*i+1] * prod;
			s %= mod;
			prod = prod * (m+n-i-1) % mod * invl(n-i, mod) % mod;
		}
		long ret = fib(m+2*n, mod) - s;
		ret %= mod;
		if(ret < 0)ret += mod;
		out.println(ret);
	}
	
	public static long fib(long n, long mod)
	{
		long a = 1, b = 1, d = 0;
		long va = 1, vb = 0;
		
		// (1 1)(1)
		// (1 0)(0)
		for(n--;n>0;n>>>=1){
			if((n&1)==1){
				long nva = (a*va+b*vb)%mod;
				long nvb = (b*va+d*vb)%mod;
				va = nva; vb = nvb;
			}
			
			long na = (a*a+b*b)%mod;
			long nb = (b*(a+d))%mod;
			long nd = (d*d+b*b)%mod;
			a = na; b = nb; d = nd;
		}
		
		return va;
	}

	
	public static long invl(long a, long mod) {
		long b = mod;
		long p = 1, q = 0;
		while (b > 0) {
			long c = a / b;
			long d;
			d = a;
			a = b;
			b = d % b;
			d = p;
			p = q;
			q = d - c * q;
		}
		return p < 0 ? p + mod : p;
	}

	
	public static void main(String[] args) throws Exception
	{
		long S = System.currentTimeMillis();
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
		long G = System.currentTimeMillis();
		tr(G-S+"ms");
	}
	
	private static boolean eof()
	{
		if(lenbuf == -1)return true;
		int lptr = ptrbuf;
		while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;
		
		try {
			is.mark(1000);
			while(true){
				int b = is.read();
				if(b == -1){
					is.reset();
					return true;
				}else if(!isSpaceChar(b)){
					is.reset();
					return false;
				}
			}
		} catch (IOException e) {
			return true;
		}
	}
	
	private static byte[] inbuf = new byte[1024];
	static int lenbuf = 0, ptrbuf = 0;
	
	private static int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
//	private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }
	private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private static double nd() { return Double.parseDouble(ns()); }
	private static char nc() { return (char)skip(); }
	
	private static String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private static char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private static char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private static int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private static int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}