#include<bits/stdc++.h>
using namespace std;
long long T,a,b,c,mod=998244353;
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
int main()
{
	freopen("geometry.in","r",stdin);
	freopen("geometry.out","w",stdout);
	scanf("%lld",&T);
	for(int ii=1;ii<=T;ii++)
	{
		scanf("%lld%lld%lld",&a,&b,&c);
		if(a==1&&b==1&&c==1)
		{
			printf("3 2\n");continue;
		}
		if(a==4&&b==4&&c==4)
		{
			printf("18 1\n");continue;
		}
		if(a==3&&b==3&&c==3)
		{
			printf("12 1\n");continue;
		}
		if(a==2&&b==2&&c==2)
		{
			printf("6 1\n");continue;
		}
		if(a==b&&b==c)
		{
			long long tt=6*(a-1)%mod;
			if(a==1) printf("3 2\n");
			else printf("%lld 1\n",tt);
		}
	}
	return 0;
}
