#include
#include
#include
using namespace std;
const int MAXN = 202020;
const int MOD = 998244353;
int fac[MAXN], facinv[MAXN];
int n, m, k;
long long quickmul(int a, int b)
{
long long ret = 1;
for(; b; b >>= 1, a = (long long)a * a % MOD)
if(b & 1)
ret = ret * a % MOD;
return ret;
}
void init()
{
fac[0] = 1;
for(int i = 1; i < MAXN; i++)
fac[i] = (long long)fac[i - 1] * i % MOD;
facinv[MAXN - 1] = quickmul(fac[MAXN - 1], MOD - 2);
for(int i = MAXN - 1; i > 0; i--)
facinv[i - 1] = (long long) facinv[i] * i % MOD;
}
long long C(int n, int m)
{
if(n < 0 || m < 0 || m > n)
return 0;
return (long long)fac[n] * facinv[m] % MOD * facinv[n - m] % MOD;
}
void solve()
{
scanf("%d%d%d", &n, &m, &k);
int ans = 0;
for(int c = 0; c * n <= k; c++)
{
if(c & 1)
ans = (ans - C(m, c) * C(k - c * n + m - 1, m - 1) % MOD + MOD) % MOD;
else
ans = (ans + C(m, c) * C(k - c * n + m - 1, m - 1)) % MOD;
}
printf("%d\n", ans);
}
int main()
{
init();
int T;
for(scanf("%d", &T); T; T--)
solve();
return 0;
}
#include
using namespace std;
#define rep(i,a,n) for (int i=a;i=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector VI;
typedef long long ll;
typedef pair PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
/*
int n,m,a[10][10],ans;
void dfs(int u,int v) {
if (u==n) {
int cnt=0;
rep(i,0,n) {
int c=0; bool val=1;
rep(j,0,m) {
c+=a[i][j];
val&=c>=0;
}
val&=c==0;
cnt+=val;
}
rep(i,0,m) {
int c=0; bool val=1;
rep(j,0,n) {
c+=a[j][i];
val&=c>=0;
}
val&=c==0;
cnt+=val;
}
if (cnt>ans) {
ans=cnt;
printf("%d\n",ans);
rep(i,0,n) rep(j,0,m) printf("%d%c",a[i][j]," \n"[j==m-1]);
}
} else {
a[u][v]=1;
dfs(u+(v+1)/m,(v+1)%m);
a[u][v]=-1;
dfs(u+(v+1)/m,(v+1)%m);
}
}
int main() {
scanf("%d%d",&n,&m);
dfs(0,0);
}
*/
int _,n,m,f[210][210];
int main() {
for (scanf("%d",&_);_;_--) {
scanf("%d%d",&n,&m);
if (n%2==1&&m%2==1) {
rep(i,0,n) {
rep(j,0,m) putchar('(');
puts("");
}
} else if (n%2==0&&m%2==1) {
rep(i,0,n/2) {
rep(j,0,m) putchar('(');
puts("");
}
rep(i,0,n/2) {
rep(j,0,m) putchar(')');
puts("");
}
} else if (n%2==1&&m%2==0) {
rep(i,0,n) {
rep(j,0,m/2) putchar('(');
rep(j,0,m/2) putchar(')');
puts("");
}
} else {
int p=min(n,m),q=max(n,m);
if (p<=4) {
rep(i,0,p) {
rep(j,0,q/2) f[i][j]=i&1;
rep(j,0,q/2) f[i][j+q/2]=(i&1)^(i!=0&&i!=p-1);
}
if (n
#include
using namespace std;
#define rep(i,a,n) for (int i=a;i=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector VI;
typedef long long ll;
typedef pair PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
int _,n;
char s[10][10],t[10];
int main() {
for (scanf("%d",&_);_;_--) {
scanf("%d",&n);
rep(i,0,3) scanf("%s",s[i]);
rep(i,0,n) {
scanf("%s",t);
int x=(t[0]-'1')/2;
int y=(t[0]-'1')%2;
int c=t[1]=='R'?3:1;
rep(j,0,c) {
swap(s[x][y],s[x+1][y]);
swap(s[x+1][y],s[x+1][y+1]);
swap(s[x+1][y+1],s[x][y+1]);
}
}
rep(i,0,3) puts(s[i]);
}
}
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include