#include<bits/stdc++.h>
using namespace std;
const int p=998244353;
long long ans[1000005],add;
long long fp(int x,int y){
	if(y==0)return(1);
	if(y==1)return(x);
	long long sum=fp(x,y/2);
	sum=(sum*sum)%p;
	if(y%2==0)return(sum);
	else return(sum*x%p);
}
int main(){
	freopen("geometry.in","r",stdin);
	freopen("geometry.out","w",stdout);
	int t,a,b,c;
	cin>>t;
	ans[1]=3;
	add=3;
	for(int i=2; i<=1000000; i++){
		add+=6;
		ans[i]=ans[i-1]+add;
	}
	while(t--){
		cin>>a>>b>>c;
		if(a==b&&a==c){
			if(a==1)cout<<ans[1]<<' '<<2<<endl;
			else cout<<ans[a]<<' '<<(fp(2,a)+fp(2,a-2))%p<<endl;
		}else{
			if(a==1){
				if(b!=c)cout<<min(b,c)*4<<' '<<1<<endl;
				else cout<<b*4-1<<' '<<b*2;
			}
			if(a==2){
				if(abs(b-c)>=2)cout<<min(b,c)*8<<' '<<1<<endl;
				else if(abs(b-c)==1){
					if(min(b,c)==1)cout<<7<<' '<<4<<endl;
					else cout<<min(b,c)*8-2<<' '<<2<<endl;
				}else{
					if(b==1)cout<<4<<' '<<1<<endl;
					else cout<<12+(b-2)*8<<' '<<5<<endl;
				}
			}
		}
	}
}
