Universal Cup Judging System

Universal Cup

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100 Hackeable ✓
Estadísticas

You are given an integer sequence $a_1, a_2, \ldots, a_n$ of length $n$, and an integer $x$.

Define a subsequence of the sequence as follows: for any non-empty set of indices $\{i_1, i_2, \cdots, i_m\}$ ($i_1 < i_2 < \cdots < i_m$) chosen from $1, \ldots, n$, taking $a_{i_1}, \ldots, a_{i_m}$ in their original order is a subsequence. Define its median as follows: sort the $m$ chosen values into $v_1 \le v_2 \le \cdots \le v_m$, then:

  • if $m$ is odd, the median is the middle value $v_{(m+1)/2}$;
  • if $m$ is even, the median is the average of the two middle values, $\frac{v_{m/2} + v_{m/2+1}}{2}$ (this average need not be an integer, but the problem only cares whether it is exactly equal to $x$).

Find the number of subsequences whose median is exactly $x$. Since this number can be very large, output it modulo $998\,244\,353$.

Note: even if two different index sets happen to pick out the exact same multiset of values (possible since the sequence may contain repeated numbers), they are still counted as two distinct subsequences. It is the index set itself, not the multiset of chosen values, that distinguishes subsequences. The empty index set is not a subsequence and is never counted.

Input

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$).

For each testcase:

  • The first line contains two integers $n$ and $x$ ($1 \le n \le 2 \times 10^5$, $-10^9 \le x \le 10^9$), representing the length of the sequence $a$ and the target median value.
  • The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($-10^9 \le a_i \le 10^9$), representing the elements of the given sequence.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \times 10^5$.

Output

For each test case, output one line with one integer: the number of subsequences whose median is exactly $x$, modulo $998\,244\,353$.

Examples

Input 1

2
5 3
1 3 5 3 2
2 0
-1 1

Output 1

14
1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.