#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<bitset>
#include<cassert>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define inf (1<<30)
#define INF (1ll<<62)
#define y1 bflaisfnmasf
#define y2 fsafgmalg
#define tm afnsjkf
#define j1 sfakf
#define j2 fasndfkas
#define fi first
#define se second
#define CLR(x,f) memset(x,f,sizeof(x))
#define CPY(x,y) memcpy(x,y,sizeof(x))
#define prt(x) cout<<#x<<":"<<x<<" "
#define prtn(x) cout<<#x<<":"<<x<<endl
#define huh(x) printf("--------case(%d)--------\n",x)
#define travel(x) for(Edge *e=h[x];e;e=e->n)
#define TLE
#define HDUE
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
typedef long long ll;
typedef double doub;
typedef complex<doub> comp;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
template<class T>
void Max(T &x,T y){
if(x<y)x=y;
}
//struct Point{
// ll x,y;//int?
// bool operator<(const Point &a)const{
// return x==a.x?y<a.y:x<a.x;
// }
// Point operator-(const Point &a)const{
// return (Point){x-a.x,y-a.y};
// }
// ll operator*(const Point &a)const{
// return x*a.x+a.y*y;
// }
// friend ll cross(Point a,Point b){
// return a.x*b.y-b.x*a.y;
// }//cross(a,b)?
//};
//bool cmpk(Point a,Point b){
// return a.y*b.x<b.y*a.x;
//}
//Point s[M];
//int conpoly(int n){
// int w=0;
// sort(s+1,s+n+1);
// for(int i=1;i<=n;i++){
// while(w>1&&(s[w]-s[w-1]^s[i]-s[w-1])>=0)w--;
// s[++w]=s[i];
// }
// return w;
//}
//struct comp{
// long double real,imag;//double?
// comp(){}
// comp(long double real_,long double imag_){
// real=real_;imag=imag_;
// }
// friend comp operator+(comp a,comp b){
// return comp(a.real+b.real,a.imag+b.imag);
// }
// friend comp operator*(comp a,comp b){
// return comp(a.real*b.real-a.imag*b.imag,a.real*b.imag+a.imag*b.real);
// }
// friend comp operator-(comp a,comp b){
// return comp(a.real-b.real,a.imag-b.imag);
// }
//}ffa[M],ffb[M],wm[M];
//int rev[M];
//void fft(comp *a,int n,int f){
// for(int i=0;i<n;i++)if(rev[i]>i)swap(a[rev[i]],a[i]);
// for(int m=1;m<n;m<<=1){
// comp wi(cos(pi/m),f*sin(pi/m));
// wm[0]=comp(1,0);
// for(int j=1;j<m;j++)wm[j]=wm[j-1]*wi;
// for(int j=0;j<n;j+=(m<<1)){
// for(int k=0;k<m;k++){
// comp x=a[j+k],y=wm[k]*a[j+k+m];
// a[j+k]=x+y;a[j+k+m]=x-y;
// }
// }
// }
// if(f==-1)for(int i=0;i<n;i++)a[i].real/=n,a[i].imag/=n;
//}
//void mulpoly(int a[],int b[],int c[],int na,int nb,int &n){
// int m=max(na,nb)<<1,l=0;
// for(n=1;n<m;n<<=1)l++;
// for(int i=1;i<n;i++)rev[i]=(rev[i>>1]>>1)|((i&1)<<l-1);
//
// for(int i=0;i<n;i++)ffa[i]=ffb[i]=comp(0,0);
// for(int i=0;i<na;i++)ffa[i]=comp(a[i],0);
// for(int i=0;i<nb;i++)ffb[i]=comp(b[i],0);
//
// fft(ffa,n,1);fft(ffb,n,1);
//
// for(int i=0;i<n;i++)ffa[i]=ffa[i]*ffb[i];
//
// fft(ffa,n,-1);
//
// for(int i=0;i<n;i++)c[i]=(int)(ffa[i].real+0.5);
//}
//struct mat{
// static const int M=100;
// int v[M][M];//long long?
// mat(){
// memset(v,0,sizeof(v));
// }
// friend mat operator*(mat a,mat b){
// mat c;
// for(int i=0;i<M;i++)
// for(int j=0;j<M;j++)
// for(int k=0;k<M;k++)
// c.v[i][j]+=a.v[i][k]*b.v[k][j];//mod?
// return c;
// }
// friend mat operator^(mat a,int x){
// mat c;
// for(int i=0;i<M;i++)c.v[i][i]=true;
// for(;x;x>>=1,a=a*a)if(x&1)c=c*a;
// return c;
// }
//};
int main(){
#ifdef TL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif
#ifdef HDU
int cas,test=0;scanf("%d",&cas);
while(cas--){
// printf("Case #%d: ",++test);
solve();
}
#endif
return 0;
}