Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future. [Image] 

Kaavi has a string $T$ of length $m$ and all the strings with the prefix $T$ are magic spells. Kaavi also has a string $S$ of length $n$ and an empty string $A$.

During the divination, Kaavi needs to perform a sequence of operations. There are two different operations: Delete the first character of $S$ and add it at the front of $A$. Delete the first character of $S$ and add it at the back of $A$.

Kaavi can perform no more than $n$ operations. To finish the divination, she wants to know the number of different operation sequences to make $A$ a magic spell (i.e. with the prefix $T$). As her assistant, can you help her? The answer might be huge, so Kaavi only needs to know the answer modulo $998\,244\,353$.

Two operation sequences are considered different if they are different in length or there exists an $i$ that their $i$-th operation is different. 

A substring is a contiguous sequence of characters within a string. A prefix of a string $S$ is a substring of $S$ that occurs at the beginning of $S$.


-----Input-----

The first line contains a string $S$ of length $n$ ($1 \leq n \leq 3000$).

The second line contains a string $T$ of length $m$ ($1 \leq m \leq n$).

Both strings contain only lowercase Latin letters.


-----Output-----

The output contains only one integer  — the answer modulo $998\,244\,353$.


-----Examples-----
Input
abab
ba

Output
12
Input
defineintlonglong
signedmain

Output
0
Input
rotator
rotator

Output
4
Input
cacdcdbbbb
bdcaccdbbb

Output
24


-----Note-----

The first test:

$\text{baba abab bbaa baab baab}$

The red ones are the magic spells. In the first operation, Kaavi can either add the first character "a" at the front or the back of $A$, although the results are the same, they are considered as different operations. So the answer is $6\times2=12$.

Difficulty: MEDIUM

Starter code:

Solutions:
import sys, inspect
strings = iter(sys.stdin.read().split())
mod = 998244353

def main():
	(s, t) = (next(strings), next(strings))
	(n, m) = (len(s), len(t))
	dp = [j == 0 for j in range(m + 1)]
	f = lambda j: ((n - i + 1 if i >= m else s[i] == t[j + i] and dp[j]) if j == 0 else 2 * dp[j] + (s[i] == t[j - 1] and dp[j - 1]) if j == m else (s[i] == t[j - 1] and dp[j - 1]) + ((i + j >= m or s[i] == t[j + i]) and dp[j])) % mod
	for i in range(n - 1, 0, -1):
		dp = [f(j) for j in range(m + 1)]
	ans = sum((2 * dp[j] for j in range(m + 1) if j == m or s[0] == t[j])) % mod
	print(ans)
	return
main()

def F(S, T):
	global s, t, n, m
	(s, t, n, m) = (S, T, len(S), len(T))
	ans = sum((2 * f(1, j) for j in range(m + 1) if j == m or t[j] == s[0]))
	return ans % mod

def f(i, j):
	if i == n:
		ans = j == 0
	elif j == 0:
		if i >= m:
			ans = n - i + 1
		else:
			ans = s[i] == t[j + i] and f(i + 1, j)
	elif j < m:
		ans = 0
		ans += s[i] == t[j - 1] and f(i + 1, j - 1)
		ans += (i + j >= m or s[i] == t[j + i]) and f(i + 1, j)
	elif j == m:
		ans = 2 * f(i + 1, j)
		ans += s[i] == t[j - 1] and f(i + 1, j - 1)
	return ans % mod


import os

def solve(S, T):
	MOD = 998244353
	N = len(S)
	M = len(T)
	dp = [[0] * (N + 1) for _ in range(N)]
	for r in range(N):
		if r >= M or S[0] == T[r]:
			dp[r][r + 1] = 2
	for s_size in range(2, N + 1):
		for t_start in range(N - s_size + 1):
			t_end = t_start + s_size
			s = S[s_size - 1]
			if t_start >= M or T[t_start] == s:
				dp[t_start][t_end] = (dp[t_start][t_end] + dp[t_start + 1][t_end]) % MOD
			if t_end > M or T[t_end - 1] == s:
				dp[t_start][t_end] = (dp[t_start][t_end] + dp[t_start][t_end - 1]) % MOD
	ans = 0
	for i in range(M, N + 1):
		ans = (ans + dp[0][i]) % MOD
	return ans

def pp(input):
	S = input().strip()
	T = input().strip()
	print(solve(S, T))
if 'paalto' in os.getcwd():
	from string_source import string_source
	pp(string_source('cacdcdbbbb\nbdcaccdbbb'))
else:
	pp(input)


from sys import stdin, stdout

def kaavi_and_magic_spell(S, T):
	MOD = 998244353
	n = len(S)
	m = len(T)
	dp = [[0 for _ in range(n)] for _ in range(n)]
	for i in range(n):
		if comp(S, T, 0, i):
			dp[i][i] = 1
	for l in range(2, n + 1):
		for i in range(n - l + 1):
			if comp(S, T, l - 1, i):
				dp[i][i + l - 1] += dp[i + 1][i + l - 1]
				dp[i][i + l - 1] %= MOD
			if comp(S, T, l - 1, i + l - 1):
				dp[i][i + l - 1] += dp[i][i + l - 2]
				dp[i][i + l - 1] %= MOD
	r = 0
	for j in range(m - 1, n):
		r += dp[0][j]
		r %= MOD
	r *= 2
	r %= MOD
	return r

def comp(S, T, i, j):
	if j >= len(T):
		return True
	return S[i] == T[j]
S = stdin.readline().strip()
T = stdin.readline().strip()
r = kaavi_and_magic_spell(S, T)
stdout.write(str(r) + '\n')


import io
import os
import sys
fileno = sys.stdin.fileno()
input = io.BytesIO(os.read(fileno, os.fstat(fileno).st_size)).readline
MOD = 998244353
S = input().strip().decode('utf8')
T = input().strip().decode('utf8')
N = len(S)
M = len(T)
D = [[0 for j in range(M)] for i in range(N)]
for j in range(M):
	if S[0] == T[j]:
		D[0][j] = 2
for i in range(1, N):
	for j in range(M):
		if S[i] == T[j]:
			if j != M - 1:
				D[i][j] = D[i - 1][j + 1]
			else:
				D[i][j] = pow(2, i, MOD)
		if i + j >= M or S[i] == T[i + j]:
			D[i][j] += D[i - 1][j]
			D[i][j] %= MOD
ans = 0
for i in range(M - 1, N):
	ans += D[i][0]
	ans %= MOD
print(ans)


S = input()
T = input()
base = 998244353
dp = [[0 for _ in range(len(S) + 1)] for _ in range(len(S) + 1)]
for j in range(1, len(S) + 1):
	if j > len(T) or S[0] == T[j - 1]:
		dp[1][j] = 2
for i in range(2, len(S) + 1):
	for j in range(1, len(S) - i + 1 + 1):
		if j > len(T) or S[i - 1] == T[j - 1]:
			dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % base
		if j + i - 1 > len(T) or S[i - 1] == T[j + i - 1 - 1]:
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % base
ans = 0
for i in range(len(T), len(S) + 1):
	ans = (ans + dp[i][1]) % base
print(ans)


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	md = 998244353
	s = SI()
	t = SI()
	sn = len(s)
	tn = len(t)
	dp = [[0] * sn for _ in range(sn + 1)]
	for j in range(sn):
		dp[1][j] = 2 if j >= tn or t[j] == s[0] else 0
	for (i, c) in enumerate(s[1:], 1):
		for j in range(sn):
			pre = dp[i][j]
			if pre == 0:
				continue
			if j > 0 and (j - 1 >= tn or t[j - 1] == c):
				dp[i + 1][j - 1] = (dp[i + 1][j - 1] + pre) % md
			if j + i < sn and (j + i >= tn or t[j + i] == c):
				dp[i + 1][j] = (dp[i + 1][j] + pre) % md
	ans = sum((dp[i][0] for i in range(tn, sn + 1))) % md
	print(ans)
main()


mod = 998244353
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline
	S = input().rstrip('\n')
	S = S[::-1]
	T = input().rstrip('\n')
	NS = len(S)
	NT = len(T)
	dp = [[0] * (NT + 1) for _ in range(NS + 1)]
	dp[0][0] = 1
	for i in range(NS):
		s = S[i]
		for j in range(NT + 1):
			if j == 0:
				if i != NS - 1:
					if T[0] == s and dp[i][0]:
						dp[i + 1][1] = (dp[i + 1][1] + dp[i][0] + min(i, NS - NT)) % mod
				elif T[0] == s and dp[i][0]:
					dp[i + 1][-1] = (dp[i + 1][-1] + dp[i][0] + NS - NT) % mod
			elif j == NT:
				dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod
			elif i != NS - 1:
				if s == T[j]:
					dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % mod
			elif s == T[j]:
				dp[i + 1][-1] = (dp[i + 1][-1] + dp[i][j]) % mod
			k = NS - (i - j) - 1
			if k >= NT:
				dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod
			elif T[k] == s:
				if i != NS - 1:
					dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod
				else:
					dp[i + 1][-1] = (dp[i + 1][-1] + dp[i][j]) % mod
					if k == 0 and dp[i][j]:
						dp[i + 1][-1] = (dp[i + 1][-1] + (NS - NT)) % mod
	print(dp[-1][-1] % mod)
main()


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)
s = input()[:-1]
t = input()[:-1]
MOD = 998244353
r_lim = len(t)
n = len(s)
dp = [[0] * (n + 1) for i in range(n + 1)]
for length in range(1, n + 1):
	for l in range(n + 1):
		r = l + length
		if r > n:
			break
		if length == 1:
			if l >= r_lim or s[0] == t[l]:
				dp[l][r] = 2
			else:
				dp[l][r] = 0
			continue
		if l >= r_lim or s[length - 1] == t[l]:
			dp[l][r] += dp[l + 1][r]
			dp[l][r] %= MOD
		if r - 1 >= r_lim or s[length - 1] == t[r - 1]:
			dp[l][r] += dp[l][r - 1]
			dp[l][r] %= MOD
ans = 0
for i in range(r_lim, n + 1):
	ans += dp[0][i]
	ans %= MOD
print(ans)


import sys
readline = sys.stdin.readline
S = input()
T = '*' + input()
(n, m) = (len(S), len(T))
mod = 998244353
dp = [[0] * (n + 5) for _ in range(n + 5)]
for i in range(n + 1):
	dp[i][i + 1] = 1
for (i, c) in enumerate(S, start=1):
	for (l, r) in zip(range(0, n + 1), range(i, n + 2)):
		if l >= m or (0 < l and T[l] == c):
			dp[l - 1][r] += dp[l][r] % mod
		if r >= m or T[r] == c:
			dp[l][r + 1] += dp[l][r] % mod
print(sum(dp[0][m:]) % mod)


def dp(S, T, n, m, mod):
	mp = modPower(n, mod)
	(rows, cols) = (n, n)
	dp = [[0] * cols for _ in range(rows)]
	for j in range(n):
		if j < m:
			c = int(S[0] == T[j])
			dp[0][j] = 2 * c
		else:
			dp[0][j] = 2
	for i in range(1, n):
		for j in range(n - i):
			if i + j < m:
				dp[i][j] = (dp[i - 1][j] * int(S[i] == T[i + j]) + dp[i - 1][j + 1] * int(S[i] == T[j])) % mod
			elif i + j >= m and j < m:
				dp[i][j] = (dp[i - 1][j + 1] * int(S[i] == T[j]) + dp[i - 1][j]) % mod
			else:
				dp[i][j] = mp[i + 1]
	r = 0
	for i in range(m - 1, n):
		r += dp[i][0] % mod
	return r % mod

def modPower(n, mod):
	mp = [0] * n
	mp[0] = 1
	for i in range(1, n):
		mp[i] = int(2 * mp[i - 1] % mod)
	return mp

def solu(S, T, n, m):
	mod = 998244353
	dpr = dp(S, T, n, m, mod)
	return dpr

def printMatrix(des, m):
	print(des)
	for i in range(len(m)):
		print(*m[i])
S = input()
T = input()
n = len(S)
m = len(T)
mod = 998244353
dpr = dp(S, T, n, m, mod)
print(dpr)


from functools import lru_cache
MOD = 998244353

def solve():
	S = input().strip()
	T = input().strip()
	N = len(S)
	M = len(T)
	dp = [[0] * N for _ in range(N)]
	for j in range(N):
		if j >= M or S[0] == T[j]:
			dp[j][j] = 2
	for i in range(2, N + 1):
		for j in range(N - i + 1):
			k = j + i - 1
			if j >= M or S[i - 1] == T[j]:
				dp[j][k] = (dp[j][k] + dp[j + 1][k]) % MOD
			if j + i - 1 >= M or S[i - 1] == T[k]:
				dp[j][k] = (dp[j][k] + dp[j][k - 1]) % MOD
	ans = 0
	for i in range(M - 1, N):
		ans = (ans + dp[0][i]) % MOD
	return ans
print(solve())


s = input()
t = input()
(n, m) = (len(s), len(t))
dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(n + 1):
	for j in range(n + 1):
		if i == j:
			dp[i][j] = 1
for i in range(n - 1, -1, -1):
	for j in range(i + 1, n + 1):
		if i >= m or t[i] == s[j - i - 1]:
			dp[i][j] += dp[i + 1][j] % 998244353
		if j - 1 >= m or t[j - 1] == s[j - i - 1]:
			dp[i][j] += dp[i][j - 1] % 998244353
total = 0
for i in range(m, n + 1):
	total += dp[0][i] % 998244353
print(total % 998244353)


import sys
from copy import copy, deepcopy
input = sys.stdin.readline
inf = 100000000000000000
mod = 998244353
S = input().strip()
n = len(S)
T = input().strip()
T = list(T)
num = len(T)
T.extend(['!'] * (n - len(T)))
f = [[0] * (n + 10) for i in range(n + 10)]
for i in range(n):
	f[i][i - 1] = 1
	f[i + 1][i] = 1
for i in range(n):
	for l in range(n):
		r = l + i
		if r >= n:
			break
		if S[i] == T[r] or T[r] == '!':
			f[l][r] += f[l][r - 1]
			f[l][r] %= mod
		if S[i] == T[l] or T[l] == '!':
			f[l][r] += f[l + 1][r]
			f[l][r] %= mod
ans = 0
for i in range(num - 1, n):
	ans += f[0][i]
	ans %= mod
print(ans % mod)


M = 998244353
S = input()
T = input()
(n, m) = (len(S), len(T))
dp = [[0] * n for _ in range(n)]
cur = S[0]
for st in range(0, n):
	if st >= m or cur == T[st]:
		dp[st][st] = 2
for width in range(2, n + 1):
	cur = S[width - 1]
	for st in range(0, n - width + 1):
		ed = st + width - 1
		if st >= m or cur == T[st]:
			dp[st][ed] = (dp[st][ed] + dp[st + 1][ed]) % M
		if ed >= m or cur == T[ed]:
			dp[st][ed] = (dp[st][ed] + dp[st][ed - 1]) % M
ans = 0
for i in range(m - 1, n):
	ans = (ans + dp[0][i]) % M
print(ans)


import os
import sys
from collections import deque
from queue import PriorityQueue
import math

class CF(object):

	def __init__(self):
		self.mod = 998244353
		self.s = input()
		self.t = input()
		self.n = len(self.s)
		self.dp = [[0] * (self.n + 1) for _ in range(self.n + 1)]
		for i in range(len(self.s) + 1):
			self.dp[0][i] = 1
		for i in range(self.n):
			if i + 1 <= len(self.t):
				if self.s[i] == self.t[i]:
					self.dp[i + 1][0] += self.dp[i][0]
					self.dp[i + 1][0] %= self.mod
			else:
				self.dp[i + 1][0] += self.dp[i][0]
				self.dp[i + 1][0] %= self.mod
			for j in range(1, len(self.s) + 1):
				if j - 1 < len(self.t):
					if self.s[i] == self.t[j - 1]:
						self.dp[i + 1][j - 1] += self.dp[i][j]
						self.dp[i + 1][j - 1] %= self.mod
				else:
					self.dp[i + 1][j - 1] += self.dp[i][j]
					self.dp[i + 1][j - 1] %= self.mod
				if j + i < len(self.t):
					if self.s[i] == self.t[j + i]:
						self.dp[i + 1][j] += self.dp[i][j]
						self.dp[i + 1][j] %= self.mod
				else:
					self.dp[i + 1][j] += self.dp[i][j]
					self.dp[i + 1][j] %= self.mod
			pass
		pass
		ans = 0
		for i in range(len(self.t), len(self.s) + 1):
			ans += self.dp[i][0]
			ans %= self.mod
		print(ans)

	def main(self):
		pass
cf = CF()
cf.main()
pass


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if not True else 1):
	s = input()
	t = input()
	mod = 998244353
	(n, m) = (len(s), len(t))
	lim = 3001
	dp = [[0] * lim for i in range(lim)]
	for i in range(m - 1, n):
		if i > m or s[i] == t[-1]:
			dp[i + 1][0] = 1
		if s[i] == t[0]:
			dp[i + 1][1] = 1
	for i in range(n - 1, 0, -1):
		for j in range(n - i + 1):
			if j >= m or s[i - 1] == t[j]:
				dp[i][j + 1] += dp[i + 1][j]
				dp[i][j + 1] %= mod
			if i + j - 1 >= m or s[i - 1] == t[i + j - 1]:
				dp[i][j] += dp[i + 1][j]
				dp[i][j] %= mod
	print(sum(dp[1]) % mod)


from sys import stdin, gettrace
from collections import Counter
if not gettrace():

	def input():
		return next(stdin)[:-1]

def modInt(mod):

	class ModInt:

		def __init__(self, value):
			self.value = value % mod

		def __int__(self):
			return self.value

		def __eq__(self, other):
			return self.value == other.value

		def __hash__(self):
			return hash(self.value)

		def __add__(self, other):
			return ModInt(self.value + int(other))

		def __sub__(self, other):
			return ModInt(self.value - int(other))

		def __mul__(self, other):
			return ModInt(self.value * int(other))

		def __floordiv__(self, other):
			return ModInt(self.value // int(other))

		def __truediv__(self, other):
			return ModInt(self.value * pow(int(other), mod - 2, mod))
	return ModInt

def main():
	ModInt = modInt(998244353)
	ss = input()
	tt = input()
	n = len(ss)
	m = len(tt)
	dp = [[ModInt(0)] * (n - i + 1) for i in range(n + 1)]
	for i in range(m, n + 1):
		dp[i][0] = ModInt(1)
	for i in range(n, 0, -1):
		for j in range(n - i + 1):
			pos = i - 1 + j
			if pos >= m or ss[i - 1] == tt[pos]:
				dp[i - 1][j] += dp[i][j]
			pos = j
			if pos >= m or ss[i - 1] == tt[pos]:
				dp[i - 1][j + 1] += dp[i][j]
	res = ModInt(0)
	for d in dp[0]:
		res += d
	print(int(res))
main()


import sys
from array import array
from typing import List, Tuple, TypeVar, Generic, Sequence, Union

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def solve():
	(s, t) = (input().rstrip(), '*' + input().rstrip())
	(n, m) = (len(s), len(t))
	mod = 998244353
	dp = [array('i', [0]) * (n + 2) for _ in range(n + 2)]
	for i in range(1, n + 2):
		dp[i][i - 1] = 1
	for (slen, c) in enumerate(s):
		for (i, j) in zip(range(n + 2), range(slen, n + 2)):
			if 0 < i < m and t[i] == c or m <= i <= n:
				dp[i][j] += dp[i + 1][j]
				if dp[i][j] >= mod:
					dp[i][j] -= mod
			if 0 < j < m and t[j] == c or m <= j <= n:
				dp[i][j] += dp[i][j - 1]
				if dp[i][j] >= mod:
					dp[i][j] -= mod
	print(sum(dp[1][m - 1:]) % mod)
solve()


def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
p = 998244353
s = input()
t = input()
n = len(s)
m = len(t)
dp = [[0 for j in range(m)] for i in range(n)]
for j in range(m):
	if s[0] == t[j]:
		dp[0][j] = 2
for i in range(1, n):
	for j in range(m):
		if s[i] == t[j]:
			if j == m - 1:
				dp[i][j] += power(2, i, p)
			else:
				dp[i][j] += dp[i - 1][j + 1]
		if i + j >= m or s[i] == t[i + j]:
			dp[i][j] += dp[i - 1][j]
		dp[i][j] = dp[i][j] % p
ans = 0
for i in range(m - 1, n):
	ans += dp[i][0]
	ans = ans % p
print(ans)
print()


from typing import List
import sys
dp = [[0 for i in range(3005)] for i in range(3005)]
a = input()
pref = input()
mod = 998244353
for lx in range(1, len(a) + 1):
	for l in range(0, len(a)):
		r = l + lx - 1
		if r >= len(a):
			break
		cur = a[r - l]
		if l == r:
			dp[l][r] = 2 if l < len(pref) and cur == pref[l] or l >= len(pref) else 0
			continue
		if l >= len(pref) or (l < len(pref) and cur == pref[l]):
			dp[l][r] += dp[l + 1][r]
		if r >= len(pref) or (r < len(pref) and cur == pref[r]):
			dp[l][r] += dp[l][r - 1]
		dp[l][r] %= mod
ans = 0
for i in range(len(pref) - 1, len(a)):
	ans += dp[0][i]
ans %= mod
print(ans)


import sys
import collections
import threading
mod = 998244353

def main():
	s = input().strip()
	t = input().strip()
	n = len(s)
	m = len(t)
	d = collections.defaultdict(list)
	for i in range(m):
		d[t[i]].append(i)
	dp = [[0] * n for _ in range(n)]
	c = s[0]
	for j in d[c]:
		dp[0][j] = 2
	for j in range(m, n):
		dp[0][j] = 2
	for i in range(1, n):
		c = s[i]
		for j in d[c]:
			if j + 1 < n:
				dp[i][j] += dp[i - 1][j + 1]
			if j - i >= 0:
				dp[i][j - i] += dp[i - 1][j - i]
			dp[i][j] %= mod
		for j in range(max(m, i), n):
			dp[i][j - i] += dp[i - 1][j - i]
			dp[i][j] %= mod
		for j in range(m, n - i):
			dp[i][j] += dp[i - 1][j + 1]
			dp[i][j] %= mod
	print(sum((dp[i][0] for i in range(m - 1, n))) % mod)
input = sys.stdin.readline
main()


S = input()
T = input()
b = 998244353
(n, m) = (len(S), len(T))
S = '7' + S
T = '7' + T
f = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(m, n + 1):
	if i > m or S[i] == T[m]:
		f[i][0] = 1
	if S[i] == T[1]:
		f[i][1] = 1
for i in reversed(range(2, n + 1)):
	for j in range(0, n - i + 2):
		if j >= m or T[j + 1] == S[i - 1]:
			f[i - 1][j + 1] = (f[i - 1][j + 1] + f[i][j]) % b
		x = j + i - 1
		if x > m or S[i - 1] == T[x]:
			f[i - 1][j] = (f[i - 1][j] + f[i][j]) % b
ans = 0
for i in range(n + 1):
	ans = (ans + f[1][i]) % b
print(ans)


import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
MOD = 998244353

def solve(s, t):
	(n, m) = (len(s), len(t))
	dp = [[0 for _ in range(m + 1)] for _ in range(n + 1)]
	dp[n][0] = 1
	for i in range(n - 1, 0, -1):
		for j in range(m + 1):
			if j == 0:
				if i >= m:
					dp[i][0] = n - i + 1
				elif s[i] == t[i]:
					dp[i][0] = dp[i + 1][0]
			elif j == m:
				dp[i][m] = 2 * dp[i + 1][m] % MOD
				if s[i] == t[m - 1]:
					dp[i][m] = (dp[i][m] + dp[i + 1][m - 1]) % MOD
			else:
				if i + j >= m or s[i] == t[i + j]:
					dp[i][j] = dp[i + 1][j]
				if s[i] == t[j - 1]:
					dp[i][j] = (dp[i][j] + dp[i + 1][j - 1]) % MOD
	ans = dp[1][m]
	for i in range(m):
		if t[i] == s[0]:
			ans = (ans + dp[1][i]) % MOD
	ans *= 2
	ans %= MOD
	return ans
s = input()
t = input()
print(solve(s, t))