You are given an array A containing N integers, where N is always even. In the array, exactly N/2 elements are even and N/2 elements are odd. You are also given an integer k. Choose one even element and one odd element from A. Let their sum be s. You need to compute the maximum possible value of the remainder (sum modulo k) over all such pairs.
Let's look at an example for better understanding:
Given
There are two evens (2, 4) and two odds (1, 3).
All pairs and remainders:
The maximum possible value of the remainder is 3. So the output is 3.
You are given two strings, S and R. Your task is to determine how many distinct ways the string R can be formed using only the characters from the substring of S. Since the number of ways can be very large, print the result modulo 998244353.
Function description
Complete the function solve() provided in the editor. This function takes the following 7 parameters and returns the required answer: