#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;

long long f(int x) {
    if (x < 0) return 0LL;
    return 1LL * x * (x + 1) / 2 % MOD;
}

int main() {
    int t;
    scanf("%d", &t);

    while (t--) {
        int n, a, b;
        scanf("%d%d%d", &n, &a, &b);

        long long c = 1LL * (n - a + 1) * (n - b + 1) % MOD;
        printf("%lld\n", (4LL * f(n - a - b + 1) * c % MOD - 4LL * f(n - a - b + 1) * f(n - a - b + 1) % MOD + MOD) % MOD);
    }
}

/* Clearink */

#include <cstdio>

inline void wint ( int x ) {
	if ( 9 < x ) wint ( x / 10 );
	putchar ( x % 10 ^ '0' );
}

const int MAXN = 100;
int N, K, M, f[MAXN + 1][MAXN * ( MAXN / 2 + 1 ) * ( MAXN >> 1 ) / 2 + 5];

inline void addeq ( int& a, const int b ) { ( a += b ) < M ? 0 : a -= M; }

inline void initDP () {
	f[0][0] = 1;
	int sbound = K * ( N / 2 + 1 ) * ( N >> 1 ) >> 1;
	for ( int i = 0; i < N; ++ i ) {
		for ( int j = 0, cur; j <= sbound; ++ j ) {
			if ( !( cur = f[i][j] ) ) continue;
			for ( int k = 0, s = j; k <= K && s <= sbound; ++ k, s += i + 1 ) {
				addeq ( f[i + 1][s], cur );
			}
		}
	}
}

inline int solve ( const int x ) {
	// k[x-1]+2k[x-2]+...+(x-1)k[1] = k[x+1]+2k[x+2]+...+(n-x)k[n].
	int sbound = x - 1 < N - x ? x - 1 : N - x, ret = 0;
	sbound = K * sbound * ( sbound + 1 ) >> 1;
	for ( int s = 0; s <= sbound; ++ s ) {
		addeq ( ret, 1ll * f[x - 1][s] * f[N - x][s] % M );
	}
	return ( ret * ( K + 1ll ) % M + M - 1 ) % M;
}

int main () {
	scanf ( "%d %d %d", &N, &K, &M );
	initDP ();
	for ( int i = 1; i <= N; ++ i ) {
		wint ( solve ( i ) );
		putchar ( '\n' );
	}
	return 0;
}