**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Matrix Stabilization
time_limit_ms: 2000
memory_limit_mb: 256
Description: You are given a matrix of size $n \times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.

Consider the algorithm for stabilizing matrix $a$:

  1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$.   2. Set $a_{ij} = a_{ij} - 1$.    3. Go to step $1$.

In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.

Your task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.

Input: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of sets of input data. This is followed by their description.

The first line of each set of input data contains two integers $n$ and $m$ ($1 \leq n, m \leq 100, n \cdot m > 1$) — the number of rows and columns of matrix $a$.

The next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$).

It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$.

Output: For each set of input data, output $n$ lines with $m$ numbers in each line — the values of the cells of matrix $a$ after the stabilization algorithm.

Examples:
input:
6
1 2
3 1
2 1
1
1
2 2
1 2
3 4
2 3
7 4 5
1 8 10
5 4
92 74 31 74
74 92 17 7
31 17 92 3
74 7 3 92
7 31 1 1
3 3
1000000000 1 1000000000
1 1000000000 1
1000000000 1 1000000000
output:
1 1
1
1
1 2
3 3
4 4 5
1 8 8
74 74 31 31
74 74 17 7
31 17 17 3
31 7 3 3
7 7 1 1
1 1 1
1 1 1
1 1 1

Note: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.

![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)

In the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.

In the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.

![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)

In the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.

![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)

Buggy Code:
import java.util.Scanner;

public class code {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();

        while (t-- > 0) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int[][] matrix = new int[n][m];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = scanner.nextInt();
                }
            }

            boolean stabilized = false;

            while (!stabilized) {
                int peakI = -1, peakJ = -1;
                int peakValue = Integer.MIN_VALUE;
                int maxNeighborValue = Integer.MIN_VALUE;

                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        if (isPeak(matrix, i, j, n, m)) {
                            if (matrix[i][j] > peakValue || (matrix[i][j] == peakValue && (i < peakI || (i == peakI && j < peakJ)))) {
                                peakValue = matrix[i][j];
                                peakI = i;
                                peakJ = j;

                                maxNeighborValue = Integer.MIN_VALUE;
                                if (i > 0) maxNeighborValue = Math.max(maxNeighborValue, matrix[i - 1][j]);
                                if (i < n - 1) maxNeighborValue = Math.max(maxNeighborValue, matrix[i + 1][j]);
                                if (j > 0) maxNeighborValue = Math.max(maxNeighborValue, matrix[i][j - 1]);
                                if (j < m - 1) maxNeighborValue = Math.max(maxNeighborValue, matrix[i][j + 1]);
                            }
                        }
                    }
                }

                if (peakI == -1) {
                    stabilized = true;
                } else {
                    matrix[peakI][peakJ] = maxNeighborValue;
                }
            }

            printMatrix(matrix, n, m);
        }

        scanner.close();
    }

    private static boolean isPeak(int[][] matrix, int i, int j, int n, int m) {
        int value = matrix[i][j];
        if (i > 0 && matrix[i - 1][j] >= value) return false;
        if (i < n - 1 && matrix[i + 1][j] >= value) return false;
        if (j > 0 && matrix[i][j - 1] >= value) return false;
        if (j < m - 1 && matrix[i][j + 1] >= value) return false;
        return true;
    }

    private static void printMatrix(int[][] matrix, int n, int m) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                System.out.print(matrix[i][j] + " ");
            }
            System.out.println();
        }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3
1 2 1
2 3 2
1 2 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ll int64_t
#define lol(a, val) memset(a, val, sizeof(a))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ld long double
#define pb push_back
#define F first
#define S second

int mod = 1e9 + 7;
int const inf = 1e18;
int const maxn = 2e6;
int const LOG = 20;
ld const eps = 1e-12;
int const N = 2e3 + 10;

void solve() {
    int n, k;
    cin >> n >> k >> mod;
    vector<int> powers(n + 1);
    powers[0] = 1;
    for (int i = 1 ; i <= n ; i++) {
        powers[i] = powers[i - 1] * 2;
        powers[i] %= mod;
    }

    vector<vector<int>> f(n, vector<int>(k + 1, 0));
    iota(all(f[0]), 0);
    f[0][0] = 1;
    vector<int> pf(k + 2);
    for (int i = 1 ; i < n ; i++) {
        for (int l = 0 ; l <= k ; l++) {
            for (int r = 0 ; l + r <= k ; r++) {
                pf[l + r + 1] += f[i - 1][l] * f[i - 1][r];
                pf[l + r + 1] %= mod;
            }
        }
        for (int v = 1 ; v <= k + 1 ; v++) {
            pf[v] += pf[v - 1];
            pf[v] %= mod;
        }
//        for (int l = 0 ; l <= k ; l++) {
//            for (int r = 0 ; l + r <= k ; r++) {
//                for (int v = l + r ; v <= k ; v++) {
//                    f[i][v] += f[i - 1][l] * f[i - 1][r];
//                    f[i][v] %= mod;
//                }
//            }
//        }
        for (int v = 0 ; v <= k ; v++) {
            f[i][v] = pf[v + 1];
        }
        pf.assign(k + 2, 0);
    }

    vector<int> dp(k + 1);
    vector<int> pr(k + 2);
    dp[k] = 1;
    for (int i = 0 ; i + 1 < n ; i++) {
        vector<int> ndp(k + 1);
        for (int r = 0 ; r <= k ; r++) {
            for (int e = 0 ; r - e > e ; e++) {
                pr[e + 1] += dp[r] * f[n - i - 2][e] % mod;
                pr[e + 1] %= mod;
                pr[r - e + 1] -= dp[r] * f[n - i - 2][e] % mod;
                pr[r - e + 1] %= mod;
                pr[r - e + 1] += mod;
                pr[r - e + 1] %= mod;
            }
        }
        for (int v = 1 ; v <= k + 1 ; v++) {
            pr[v] += pr[v - 1];
            pr[v] %= mod;
        }
//        for (int r = 0 ; r < k + 1 ; r++) {
//            for (int e = 0 ; r - e > e ; e++) {
//                for (int t = e + 1 ; t + e <= r ; t++) {
//                    ndp[t] += dp[r] * f[n - i - 2][e] % mod;
//                    ndp[t] %= mod;
//                }
//            }
//        }
        for (int j = 0 ; j <= k ; j++) {
            dp[j] = pr[j];
        }
        for (int j = 0 ; j <= k ; j++) {
            dp[j] *= 2;
        }
        pr.assign(k + 2, 0);
    }
    int ans = 0;
    for (int i = 0 ; i <= k ; i++) {
        ans += dp[i];
        ans %= mod;
    }
    cout << ans << '\n';
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int tt;
    tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
2 2 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
/*    _   __   ___    _   ____    _    _        _____    ___     _____
     | | / /  / _ \  | | |  _ \  | |  | |      |___  |  / _ \   |  ___|
     | |/ /  | |_| | | | | |_| | |  \/  |         / /  | |_| |  | |__
     |   /   |  _  | | | |  _ /  | |\/| |        / /   |  _  |  |  __|
     | |\ \  | | | | | | | | \ \ | |  | |       / /__  | | | |  | |
     |_| \_\ |_| |_| |_| |_| |_| |_|  |_|      |_____| |_| |_|  |_|      */
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#else
#define kar(...)
#endif
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define endl '\n'
#pragma gcc optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

int N = 3e5 + 30, mod = 1e9 + 7, INF = 1e18 + 10;

int binpow(ll a, ll k, ll res = 1, int Mod = mod) {
    while (k) {
        if (k % 2) res = (res * a) % Mod;
        a = (a * a) % Mod;
        k /= 2;
    }
    return res;
}

int mult(ll a, ll b, ll Mod = mod) {
    b %= Mod;
    return a % Mod * b % Mod;
}

int add(int a, int b, int Mod = mod) { return ((a % Mod + b % Mod) % Mod + Mod) % Mod; }

int n, k;
int dp[2][505][505];

int work(int depth, int rem, int flag = true) {
    if (depth == n) return 1;
    int& ret = dp[flag][depth][rem];
    if (ret != -1) return ret;
    ret = 0;

    vector<int> pref(rem + 2);
    for (int j = 0; j <= rem; j++) {
        pref[j] = work(depth + 1, j, false);
        if (j) pref[j] = add(pref[j], pref[j - 1]);
    }
    if (flag) {
        for (int i = 1; i <= rem; i++) {
            int curr = work(depth + 1, i, true);

            curr = mult(curr, pref[min(i - 1, rem - i)]);
            curr = mult(curr, 2);

            ret = add(ret, curr);
        }
    } else {
        for (int i = 0; i <= rem; i++) {
            int curr = work(depth + 1, i, false);
            curr = mult(curr, pref[rem - i]);
            ret = add(ret, curr);
        }
    }
    return ret;

}

void Solve() {

    cin >> n >> k >> mod;

    for (int i = 1; i <= n; i++) for (int j = 0; j <= k; j++) for (int f = 0; f < 2; f++) dp[f][i][j] = -1;
    cout << work(1, k) << endl;

}

int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r",stdin), freopen("output.txt", "w",stdout);
#endif
    ios::sync_with_stdio(0), cin.tie(0);
    int Test_case = 1;
    cin >> Test_case;
    while (Test_case--) Solve();
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;

int main () {
    int t;
    cin >> t;

    for(int test = 0; test < t; test ++){
        int n;
        int k;
        long long p;

        cin >> n;
        cin >> k;
        cin >> p;

        long long dp[n][k + 1];
        long long dp2[n][k + 1];
        for(int i = 0; i < n; i ++){
            dp[i][0] = 1;
            dp2[i][0] = 0;
        }
        for(int i = 1; i <= k; i ++){
            dp[0][i] = 1;
            dp2[0][i] = 1;
        }

        for(int i = 1; i < n; i ++){
            for(int j = 0; j <= k; j ++){
                dp[i][j] = 0;
                for(int small = 0; small <= j; small ++){
                    for(int big = small; small + big <= j; big ++){
                        int mult = 2;
                        if(big == small) mult = 1;
                        dp[i][j] = (dp[i][j] + (mult * ((dp[i - 1][big] * dp[i - 1][small]) % p)) % p) % p;
                    }
                }

                dp2[i][j] = 0;
                for(int small = 0; small <= j; small ++){
                    for(int big = small + 1; small + big <= j; big ++){
                        dp2[i][j] = (dp2[i][j] + (2 * ((dp2[i - 1][big] * dp[i - 1][small]) % p)) % p) % p;
                    }
                }
                // cout << i << ", " << j << ": " << dp2[i][j] << endl;
            }
            // cout << endl;
        }

        cout << dp2[n - 1][k] << endl;
        // cout << "NEXT" << endl;
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
1 1 998244353
2 1 998244353
3 2 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
from sys import stdin

def pow(a, b, mod):
    m = 0
    y = 1
    factor = a
    ret = 1
    while b > 0:
        if ((1 << m) & b) > 0:
            b -= y
            ret = (ret * factor) % mod
        factor = (factor * factor) % mod
        y *= 2
        m += 1
    return ret

def cb(x, l, mod):
    top = x + pow(2, l, mod) - 2 #might break?
    bot = x
    ret = 1
    for i in range(x):
        ret = (ret * (top - i + mod) * pow(bot-i, mod-2, mod)) % mod
    return ret

t = int(stdin.readline())

for z in range(t):
    n,k,mod = map(int, stdin.readline().split())
    dp = [0] * (k + 1)
    temp = [0] * (k + 1)
    dp[k] = 1
    mult = 1
    for i in range(n-1):
        mult = (mult * 2) % mod

    for i in range(n-1):

        sizes = [0] * (k)
        sizes[0] = 1
        for j in range(1, k):
            sizes[j] = (sizes[j - 1] + cb(j, n-1-i, mod)) % mod
            #sizes[j] = (sizes[j - 1] * mult ) % mod

        for j in range(1, k+1):
            for p in range(1, j+1):
                temp[p] = (temp[p] + dp[j] * sizes[min(j - p, p-1)]) % mod

        for j in range(1, k+1):
            dp[j] = temp[j] % mod
            temp[j] = 0
        if mult % 2 != 0:
            mult += mod
        mult //= 2
    x = 0
    mult = 1
    for i in range(n-1):
        mult = (mult * 2) % mod
    ans = (sum(dp) % mod * mult) % mod
    if n == 1:
        ans = 1

    print(ans)
    t -= 1

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
1 1 998244353
2 2 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
from sys import stdin

t = int(stdin.readline())

for z in range(t):
    n,k,mod = map(int, stdin.readline().split())
    dp = [0] * (k + 1)
    temp = [0] * (k + 1)
    dp[k] = 1
    mult = 1
    for i in range(n-1):
        mult = (mult * 2) % mod

    for i in range(n-1):
        sizes = [0] * (k)
        sizes[0] = 1
        for j in range(1, k):
            sizes[j] = (sizes[j - 1] * mult ) % mod

        for j in range(1, k+1):
            for p in range(1, j+1):
                temp[p] += dp[j] * sizes[min(j - p, p-1)]

        for j in range(1, k+1):
            dp[j] = temp[j] % mod
            temp[j] = 0
        if mult % 2 != 0:
            mult += mod
        mult //= 2
    mult = 1
    for i in range(n-1):
        mult = (mult * 2) % mod
    ans = (sum(dp) * mult) % mod
    if n == 1:
        ans = 1

    print(ans)
    t -= 1

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
2 2 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
import sys
input = sys.stdin.readline

def modpow(x, y, mod):
    res = 1
    while y:
        if y & 1: res = (res * x) % mod
        x = (x * x) % mod
        y >>= 1

    return res

def modinverse(x, mod):
    return modpow(x, mod-2, mod)

def solve(testcase):
    n, k, p = map(int, input().split())

    prefix_base_tree = [0 for _ in range(n*(k+1))]
    for i in range(1, n):
        child_tree = (modpow(2, i, p) + p - 1) % p
        for j in range(0, k+1):
            prefix_base_tree[i*(k+1)+j] = modpow(child_tree, j, p) % p
            if j > 0: prefix_base_tree[i*(k+1)+j] = (prefix_base_tree[i*(k+1)+j] + prefix_base_tree[i*(k+1)+j-1]) % p

    dp = [0 for _ in range(n*(k+1))]
    for j in range(k+1): dp[j] = 1
    for i in range(1, n):
        for j in range(1, k+1):
            for win in range(1, j+1):
                win_side = dp[(i-1)*(k+1)+win]

                max_lose_allowed = min(j - win, win - 1)

                lose_side = prefix_base_tree[i*(k+1)+max_lose_allowed]

                dp[i*(k+1)+j] += (2 * ((win_side * lose_side) % p)) % p
                dp[i*(k+1)+j] %= p

    print(dp[-1])

if __name__ == '__main__':
    t = int(input())
    for testcase in range(t):
        solve(testcase + 1)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
1 13 998244353
2 1 998244353
3 2 998244853
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
import java.io.*;
import java.util.*;

public class Main {
boolean MULTI_CASE = true;
boolean ALWAYS_FLUSH = false;

void go() {
    int n = nextInt();
    int m = nextInt();
    int P = nextInt();
    m++;
    long[][] a = new long[n][m];
    long[][] b = new long[n][m];
    long[][] asub = new long[n][m];
    long[][] bsub = new long[n][m];
    for (int i = 0; i < m; i++) {
        a[0][i] = 1;
        b[0][i] = 1;
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; j + k < m; k++) {
                if (j > k) {
                    asub[i][j + k] = (asub[i][j + k] + a[i - 1][j] * b[i - 1][k]) % P;
                } else if (j < k) {
                    asub[i][j + k] = (asub[i][j + k] + b[i - 1][j] * a[i - 1][k]) % P;
                }
                bsub[i][j + k] = (bsub[i][j + k] + b[i - 1][j] * b[i - 1][k]) % P;
            }
            for (int k = 0; k < m; k++) {
                a[i][k] = (asub[i][k] + (k > 0 ? a[i][k - 1] : 0)) % P;
                b[i][k] = (bsub[i][k] + (k > 0 ? b[i][k - 1] : 0)) % P;
            }
        }
    }
    sl(a[n - 1][m - 1]);
}

/**
 * Input.
 */
InputStream inStream;
byte[] inBuff = new byte[1024];
int inBuffCursor = 0, inBuffLen = 0;

boolean isVisibleChar(int c) {
    return 33 <= c && c <= 126;
}

boolean hasNextByte() {
    if (inBuffCursor < inBuffLen) return true;
    inBuffCursor = 0;
    try {
        inBuffLen = inStream.read(inBuff);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
    return inBuffLen > 0;
}

boolean hasNext() {
    while (hasNextByte() && !isVisibleChar(inBuff[inBuffCursor])) inBuffCursor++;
    return hasNextByte();
}

int nextByte() {
    return hasNextByte() ? inBuff[inBuffCursor++] : -1;
}

String next() {
    if (!hasNext()) throw new RuntimeException("no next.");
    StringBuilder sb = new StringBuilder();
    int b = nextByte();
    while (isVisibleChar(b)) {
        sb.appendCodePoint(b);
        b = nextByte();
    }
    return sb.toString();
}

long nextLong() {
    if (!hasNext()) throw new RuntimeException("no next.");
    long result = 0;
    boolean negative = false;
    int b = nextByte();
    if (b < '0') {
        if (b == '-') negative = true;
        else if (b != '+') throw new RuntimeException("long number must start with +/-.");
        b = nextByte();
    }
    while (isVisibleChar(b)) {
        if (b < '0' || b > '9') throw new RuntimeException("wrong digit in long:" + (char) b);
        // NOTE: may overflow here, even if it is a valid Long, eg.-(1<<63).
        result = result * 10 + (b - '0');
        b = nextByte();
    }
    return negative ? -result : result;
}

int nextInt() {
    long x = nextLong();
    if (x < Integer.MIN_VALUE || x > Integer.MAX_VALUE)
        throw new RuntimeException("int overflow:" + x);
    return (int) x;
}

double nextDouble() {
    return Double.parseDouble(next());
}

/**
 * Output.
 */
PrintWriter printOut = new PrintWriter(System.out);

void so(Object obj, boolean newLine) {
    if (newLine) printOut.println(obj);
    else printOut.print(obj);
    if (ALWAYS_FLUSH) printOut.flush();
}

void so(Object obj) {
    so(obj, false);
}

void sl(Object obj) {
    so(obj, true);
}

void sl() {
    sl("");
}

/**
 * Main.
 */
void mainGo() {
    try {
        inStream = new FileInputStream("src/main.in");
        ALWAYS_FLUSH = true;
    } catch (Exception e) {
        inStream = System.in;
    }
    while (hasNext()) {
        if (MULTI_CASE) {
            int T = nextInt();
            if (T == 0) break;
            for (int i = 0; i < T; ++i) {
                go();
            }
        } else {
            go();
        }
    }
    printOut.flush();
}

public static void main(String[] args) throws Exception {
    new Main().mainGo();
}
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to focus on edge cases and scenarios that are likely to cause issues. Here are the steps to think through this:

1. **Understand the Buggy Code**:
   - The code appears to be implementing a dynamic programming solution to count the number of different deterministic max-heaps.
   - The bug might be in the way it handles the transitions between states, especially in the nested loops.

2. **Identify Potential Bugs**:
   - The code uses `a` and `b` arrays to store intermediate results, and `asub` and `bsub` to accumulate values.
   - The transition logic in the nested loops might be flawed, especially when `j > k` or `j < k`.

3. **Choose Edge Cases**:
   - Small values of `n` and `k` to ensure the test case is small and manageable.
   - Values of `n` and `k` that are equal to test symmetry.
   - Values of `n` and `k` where `k` is much larger than `n` to test the limits of the transition logic.

4. **Generate the Test Input**:
   - We will generate a test input with a single test case to focus on a specific edge case.
   - Let's choose `n = 3` and `k = 3` to test the symmetry and the transition logic.

Here is the test input:

```plaintext
1
3 3 100000037
```

This test input is small and valid, focusing on a scenario where `n` and `k` are equal, which should expose any issues in the transition logic of the buggy code.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
#include <bits/stdc++.h>
#define pii pair<int, int>
#define task "hihi"

using namespace std;
const int N = 5e2 + 5, MOD = 1e9 + 7;

void solve(){
    int n, k, p; cin >> n >> k >> p;
    vector<vector<vector<int>>> dp(2, vector<vector<int>>(n + 1, vector<int>(k + 1, 0)));
    for(int i = 0; i <= k; i++) dp[0][1][i] = 1;
    for(int i = 2; i <= n; i++){
        for(int sz1 = 0; sz1 <= k; sz1++){
            for(int sz2 = 0; sz2 + sz1 <= k; sz2++){
                for(int x = 0; x < 2; x++){
                    for(int y = 0; y < 2; y++){
                        int final = 0;
                        if(sz1 >= sz2) final |= x;
                        if(sz2 >= sz1) final |= y;
                        if(sz1 == sz2) final = 1;
                        int add = (1LL * dp[x][i - 1][sz1] * dp[y][i - 1][sz2]) % MOD;
                        (dp[final][i][sz1 + sz2] += add);
                        if(dp[final][i][sz1 + sz2] >= p) dp[final][i][sz1 + sz2] -= p;
                    }
                }
            }
        }
        for(int j = 0; j < 2; j++){
            for(int sz = 1; sz <= k; sz++){
                (dp[j][i][sz] += dp[j][i][sz - 1]) %= p;
            }
        }
    }
    cout << dp[0][n][k] << '\n';
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifdef Pemguimn
    freopen("local.inp", "r", stdin);
    #endif // Pemguimn

    //freopen(task".inp", "r", stdin);
    //freopen(task".out", "w", stdout);

    int t = 1;
    cin >> t;

    while(t--){
        solve();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
/*    _   __   ___    _   ____    _    _        _____    ___     _____
     | | / /  / _ \  | | |  _ \  | |  | |      |___  |  / _ \   |  ___|
     | |/ /  | |_| | | | | |_| | |  \/  |         / /  | |_| |  | |__
     |   /   |  _  | | | |  _ /  | |\/| |        / /   |  _  |  |  __|
     | |\ \  | | | | | | | | \ \ | |  | |       / /__  | | | |  | |
     |_| \_\ |_| |_| |_| |_| |_| |_|  |_|      |_____| |_| |_|  |_|      */
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#else
#define kar(...)
#endif
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define endl '\n'

int N = 3e5 + 30, mod = 1e9 + 7, INF = 1e18 + 10;

int mult(ll a, ll b, ll Mod = mod) {
    b %= Mod;
    return a % Mod * b % Mod;
}

int add(int a, int b, int Mod = mod) { return ((a % Mod + b % Mod) % Mod + Mod) % Mod; }

int n, k;
int dp[505][505][2];
int pref[505][505];

void Solve() {
    cin >> n >> k >> mod;

    for (int i = 0; i <= n; i++) for (int j = 0; j <= k; j++) for (int f = 0; f < 2; f++) dp[i][j][f] = pref[i][j] = 0;

    for (int j = 0; j <= k; j++)
        for (int f = 0; f < 2; f++) {
            dp[n][j][f] = 1;
            pref[n][j] = j + 1;
        }
    for (int dep = n - 1; dep >= 1; dep--) {
        for (int rem = 0; rem <= k; rem++) {
            for (int i = 0; i <= rem; i++) {
                int curr = 0;
                if (i) curr = mult(dp[dep + 1][i][1], pref[dep + 1][min(i - 1, rem - i)]);
                curr = mult(curr, 2);
                dp[dep][rem][1] = add(dp[dep][rem][1], curr);

                curr = mult(dp[dep + 1][i][0], pref[dep + 1][rem - i]);
                dp[dep][rem][0] = add(dp[dep][rem][0], curr);
            }

            pref[dep][rem] = dp[dep][rem][0];
            if (rem) pref[dep][rem] = add(dp[dep][rem][0], pref[dep][rem - 1]);
        }
    }

    cout << dp[1][k][1] << endl;

}

int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r",stdin), freopen("output.txt", "w",stdout);
#endif
    ios::sync_with_stdio(0), cin.tie(0);
    int Test_case = 1;
    cin >> Test_case;
    while (Test_case--) Solve();
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int modInverse(int a, ll M)
{
  ll m0 = M;
  int y = 0, x = 1;
  if (M == 1)return 0;
  while(a>1) {
    int q = a/ M;
    int t = M;M = a % M, a= t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0)x += m0;
  return x;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(0);
    int t;
    cin>>t;
    while(t--)
    {
      ll n,k,mod;
      cin>>n>>k>>mod;
      vector<int> dp(k+1);
      for(int i=0;i<=k;i++)
      dp[i]=1;
      int a1=1;
      for(int i=2;i<=n;i++)
      {
        vector<int> nxt(k+1,0);
        a1=(a1*2)%mod;
        for(int j=1;j<=k;j++)
        {
          int bin=1;
          int a2=(a1-2+mod)%mod;
          for(int x=0;x<j and j+x<=k;x++)
          {
            nxt[j+x]=((ll)nxt[j+x]+((ll)dp[j]*(ll)bin)%mod)%mod;
            bin=(bin*(a2+x+1))%mod;
            bin=((ll)bin*(ll)modInverse(x+1,mod))%mod;
          }
          nxt[j]=((ll)nxt[j]+(ll)nxt[j-1])%mod;
        }
        dp=nxt;
      }
      a1=1;
      for(int i=0;i<n-1;i++)
      a1=((ll)a1*2)%mod;
      dp[k]=((ll)dp[k]*a1)%mod;
      cout<<dp[k]<<endl;
    }

    return 0;

}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
1 1 998244353
2 2 998244353
3 3 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def solve_case():

    n, k, p = map(int, input().split())

    dp1 = [[0] * (k + 1) for _ in range(n)]
    ps_prev = [0] * (k + 2)

    for d in range(n):
        for x in range(k + 1):
            if d == 0:
                dp1[d][x] = 1
            else:
                for x1 in range(x + 1):
                    x2_min = 0
                    x2_max = x - x1
                    dp1[d][x] += dp1[d - 1][x1] * (ps_prev[x2_max + 1] - ps_prev[x2_min])
                    dp1[d][x] %= p

        ps_prev = [0] * (k + 2)
        for i in range(k + 1):
            ps_prev[i + 1] = ps_prev[i] + dp1[d][i]
            ps_prev[i + 1] %= p

    dp2 = [[0] * (k + 1) for _ in range(n)]
    ps_prev = [0] * (k + 2)
    for d in range(n):
        for x in range(k + 1):
            if d == 0:
                dp2[d][x] = 1
            else:
                for x1 in range(1, x + 1):
                    x2_min = 0
                    x2_max = min(x1 - 1, x - x1)
                    dp2[d][x] += 2 * dp2[d - 1][x1] * (ps_prev[x2_max + 1] - ps_prev[x2_min])
                    dp2[d][x] %= p
        ps_prev = [0] * (k + 2)
        for i in range(k + 1):
            ps_prev[i + 1] = ps_prev[i] + dp1[d][i]
            ps_prev[i + 1] %= p

    ans = dp2[n - 1][k]
    return ans

ans = []
for _ in range(int(input())):
    ans += [str(solve_case())]
print("\n".join(ans))

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
1 1 998244353
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
import sys
import math

def add(a, b, MOD):
    return (a + b) % MOD

def mul(a, b, MOD):
    return (a * b) % MOD

def sub(a, b, MOD):
    return (a - b + MOD) % MOD

def binpow(a, b, MOD):
    res = 1
    while b:
        if b % 2 == 1:
            res = mul(res, a, MOD)
        a = mul(a, a, MOD)
        b //= 2
    return res

def inv(a, MOD):
    return binpow(a, MOD - 2, MOD)

def C(n, k, fact, MOD):
    return mul(fact[n], inv(mul(fact[k], fact[n - k], MOD), MOD), MOD)

def solve(n, k, MOD):
    if n == 1:
        print(1)
        return
    dp = [[0] * (k + 1) for _ in range(n + 1)]
    for d in range(1, k + 1):
        dp[1][d] = (d + 1) // 2

    fact = [1] * (k + 1)
    for i in range(1, k + 1):
        fact[i] = mul(fact[i - 1], i, MOD)

    coef = [[0] * (k + 1) for _ in range(n + 1)]
    st = 1
    for i in range(1, n + 1):
        st = mul(st, 2, MOD)
        tmp = sub(st, 1, MOD)
        cur = tmp
        coef[i][0] = 1
        for d in range(1, k + 1):
            coef[i][d] = mul(cur, inv(fact[d], MOD), MOD)
            tmp = add(tmp, 1, MOD)
            cur = mul(tmp, cur, MOD)

    pref = [[0] * (k + 1) for _ in range(n + 1)]
    pref[1][0] = 0
    for d in range(1, k + 1):
        pref[1][d] = add(dp[1][d], pref[1][d - 1], MOD)

    for h in range(2, n):
        for d in range(k + 1):
            for j in range(d // 2 + 1, d + 1):
                sum = pref[h - 1][j]
                dp[h][d] = add(dp[h][d], mul(coef[h][d - j], sum, MOD), MOD)
        pref[h][0] = 0
        for d in range(1, k + 1):
            pref[h][d] = add(dp[h][d], pref[h][d - 1], MOD)

    for d in range(k + 1):
        j = d
        sum = 0
        for r in range(d + 1):
            sum = add(sum, dp[n - 1][r], MOD)
        dp[n][d] = add(dp[n][d], sum, MOD)

    print(mul(dp[n][k], binpow(2, n - 1, MOD), MOD))

def main():
    input = sys.stdin.readline
    t = int(input())
    for _ in range(t):
        n, k, MOD = map(int, input().split())
        solve(n, k, MOD)

if __name__ == "__main__":
    main()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, let's consider the following:

1. **Edge Cases**:
   - When `n` is 1, the tree is just a single node.
   - When `k` is 1, only one operation is performed.
   - When `n` is small (e.g., 2 or 3), the tree is small and easier to visualize and verify the correctness of the algorithm.
   - When `k` is close to `n`, the number of operations is close to the number of nodes, which can stress the algorithm.

2. **Specific Values**:
   - Choose a small prime number for `p` to ensure the modulo operations are simple and can be easily verified.
   - Use values for `n` and `k` that are not too large but can still expose issues in the algorithm.

3. **Multiple Test Cases**:
   - Include multiple test cases to cover different scenarios.

Given these considerations, here is a small-scale test input that is complete and valid:

```plaintext
4
1 1 998244353
2 1 998244353
3 2 998244353
3 3 998244353
```

This test input includes:
- A single node tree with one operation.
- A tree with three nodes and one operation.
- A tree with seven nodes and two operations.
- A tree with seven nodes and three operations.

These test cases should help in identifying any issues in the buggy code, especially in how it handles small and simple trees.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
import java.util.*;

public class Main {
    static final int MOD = 1000000007; // Assuming a default MOD value

    public static void solve(Scanner scanner) {
        int numLevels = scanner.nextInt();
        int maxSum = scanner.nextInt();
        int modulo = scanner.nextInt();

        List<Integer> validDp = new ArrayList<>(Collections.nCopies(maxSum + 1, 1));
        List<Integer> invalidDp = new ArrayList<>(Collections.nCopies(maxSum + 1, 1));

        for (int level = 2; level <= numLevels; level++) {
            List<Integer> newValidDp = new ArrayList<>(Collections.nCopies(maxSum + 1, 0));
            List<Integer> newInvalidDp = new ArrayList<>(Collections.nCopies(maxSum + 1, 0));

            for (int sum1 = 0; sum1 <= maxSum; sum1++) {
                for (int sum2 = 0; sum2 <= maxSum; sum2++) {
                    if (sum1 + sum2 > maxSum)
                        break;
                    newInvalidDp.set(sum1 + sum2, (newInvalidDp.get(sum1 + sum2) + (int)((long)invalidDp.get(sum1) * invalidDp.get(sum2) % modulo)) % modulo);

                    if (sum1 != sum2) {
                        newValidDp.set(sum1 + sum2, (newValidDp.get(sum1 + sum2) + (int)((long)validDp.get(Math.max(sum1, sum2)) * invalidDp.get(Math.min(sum1, sum2)) % modulo)) % modulo);
                    }
                }
            }

            for (int i = 1; i <= maxSum; i++) {
                newValidDp.set(i, (newValidDp.get(i) + newValidDp.get(i - 1)) % modulo);
                newInvalidDp.set(i, (newInvalidDp.get(i) + newInvalidDp.get(i - 1)) % modulo);
            }

            validDp = newValidDp;
            invalidDp = newInvalidDp;
        }

        System.out.println(validDp.get(maxSum));
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numTests = scanner.nextInt();

        while (numTests-- > 0) {
            solve(scanner);
        }

        scanner.close();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 3 100000037
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Deterministic Heap (Easy Version)
time_limit_ms: 3000
memory_limit_mb: 512
Description: This is the easy version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on $n$ and $t$. You can make hacks only if both versions of the problem are solved.

Consider a perfect binary tree with size $2^n - 1$, with nodes numbered from $1$ to $2^n-1$ and rooted at $1$. For each vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), vertex $2v$ is its left child and vertex $2v + 1$ is its right child. Each node $v$ also has a value $a_v$ assigned to it.

Define the operation $\mathrm{pop}$ as follows:

  1. initialize variable $v$ as $1$;    2. repeat the following process until vertex $v$ is a leaf (i.e. until $2^{n - 1} \le v \le 2^n - 1$);      1. among the children of $v$, choose the one with the larger value on it and denote such vertex as $x$; if the values on them are equal (i.e. $a_{2v} = a_{2v + 1}$), you can choose any of them;      2. assign $a_x$ to $a_v$ (i.e. $a_v := a_x$);      3. assign $x$ to $v$ (i.e. $v := x$);    3. assign $-1$ to $a_v$ (i.e. $a_v := -1$).

Then we say the $\mathrm{pop}$ operation is deterministic if there is a unique way to do such operation. In other words, $a_{2v} \neq a_{2v + 1}$ would hold whenever choosing between them.

A binary tree is called a max-heap if for every vertex $v$ ($1 \le v \le 2^{n - 1} - 1$), both $a_v \ge a_{2v}$ and $a_v \ge a_{2v + 1}$ hold.

A max-heap is deterministic if the $\mathrm{pop}$ operation is deterministic to the heap when we do it for the first time.

Initially, $a_v := 0$ for every vertex $v$ ($1 \le v \le 2^n - 1$), and your goal is to count the number of different deterministic max- heaps produced by applying the following operation $\mathrm{add}$ exactly $k$ times:

  * Choose an integer $v$ ($1 \le v \le 2^n - 1$) and, for every vertex $x$ on the path between $1$ and $v$, add $1$ to $a_x$.

Two heaps are considered different if there is a node which has different values in the heaps.

Since the answer might be large, print it modulo $p$.

Input: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

The first line of each test case contains three integers $n, k, p$ ($1 \le n, k \le 500$, $10^8 \le p \le 10^9$, $p$ is a prime).

It is guaranteed that the sum of $n$ and the sum of $k$ over all test cases does not exceed $500$.

Output: For each test case, output a single line containing an integer: the number of different deterministic max-heaps produced by applying the aforementioned operation $\mathrm{add}$ exactly $k$ times, modulo $p$.

Examples:
input:
7
1 13 998244353
2 1 998244353
3 2 998244853
3 3 998244353
3 4 100000037
4 2 100000039
4 3 100000037
output:
1
2
12
52
124
32
304

input:
1
500 500 100000007
output:
76297230

input:
6
87 63 100000037
77 77 100000039
100 200 998244353
200 100 998244353
32 59 998244853
1 1 998244353
output:
26831232
94573603
37147649
847564946
727060898
1

Note: For the first testcase, there is only one way to generate $a$, and such sequence is a deterministic max-heap, so the answer is $1$.

For the second testcase, if we choose $v = 1$ and do the operation, we would have $a = [1, 0, 0]$, and since $a_2 = a_3$, we can choose either of them when doing the first $\mathrm{pop}$ operation, so such heap is not a deterministic max-heap.

And if we choose $v = 2$, we would have $a = [1, 1, 0]$, during the first $\mathrm{pop}$, the following would happen:

  * initialize $v$ as $1$    * since $a_{2v} > a_{2v + 1}$, choose $2v$ as $x$, then $x = 2$    * assign $a_x$ to $a_v$, then $a = [1, 1, 0]$    * assign $x$ to $v$, then $v = 2$    * since $v$ is a leaf, assign $-1$ to $a_v$, then $a = [1, -1, 0]$

Since the first $\mathrm{pop}$ operation is deterministic, this is a deterministic max-heap. Also, if we choose $v = 3$, $a$ would be a deterministic max-heap, so the answer is $2$.

Buggy Code:
import java.io.*;
import java.util.*;

public class Solution {
    static final int DEFAULT_MOD = 1000000007; // Assuming a default MOD value

    public static void solveProblem(BufferedReader reader) throws IOException {
        String[] inputs = reader.readLine().split(" ");
        int numLevels = Integer.parseInt(inputs[0]);
        int maxSum = Integer.parseInt(inputs[1]);
        int modulo = Integer.parseInt(inputs[2]);

        List<Integer> validSeq = new ArrayList<>(Collections.nCopies(maxSum + 1, 1));
        List<Integer> invalidSeq = new ArrayList<>(Collections.nCopies(maxSum + 1, 1));

        for (int level = 2; level <= numLevels; level++) {
            List<Integer> newValidSeq = new ArrayList<>(Collections.nCopies(maxSum + 1, 0));
            List<Integer> newInvalidSeq = new ArrayList<>(Collections.nCopies(maxSum + 1, 0));

            for (int sum1 = 0; sum1 <= maxSum; sum1++) {
                for (int sum2 = 0; sum2 <= maxSum; sum2++) {
                    if (sum1 + sum2 > maxSum)
                        break;
                    newInvalidSeq.set(sum1 + sum2, (newInvalidSeq.get(sum1 + sum2) + (int)((long)invalidSeq.get(sum1) * invalidSeq.get(sum2) % modulo)) % modulo);

                    if (sum1 != sum2) {
                        newValidSeq.set(sum1 + sum2, (newValidSeq.get(sum1 + sum2) + (int)((long)validSeq.get(Math.max(sum1, sum2)) * invalidSeq.get(Math.min(sum1, sum2)) % modulo)) % modulo);
                    }
                }
            }

            for (int i = 1; i <= maxSum; i++) {
                newValidSeq.set(i, (newValidSeq.get(i) + newValidSeq.get(i - 1)) % modulo);
                newInvalidSeq.set(i, (newInvalidSeq.get(i) + newInvalidSeq.get(i - 1)) % modulo);
            }

            validSeq = newValidSeq;
            invalidSeq = newInvalidSeq;
        }

        System.out.println(validSeq.get(maxSum));
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int numTests = Integer.parseInt(reader.readLine());

        while (numTests-- > 0) {
            solveProblem(reader);
        }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3 4 100000037
```