#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll ksm(ll a,ll b){
	ll ans=1,base=a;
	while(b>0){
		if(b&1){
			ans=ans*base%mod;
		}
		base=base*base%mod;
		b>>=1;
	}
	return ans;
}
ll T,a,b,c;
int main(){
	freopen("geometry.in","r",stdin);
	freopen("geometry.out","w",stdout);
	cin>>T;
	while(T--){
		cin>>a>>b>>c;
		if(a==1) cout<<2<<" ";
		else cout<<a+a*2*a<<" ";
		if(a==1) cout<<1<<endl;
		else cout<<ksm(a-1,a)<<endl;
	}
	return 0;
}
