#include<bits/stdc++.h>#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0);#define mp(a, b) make_pair(a, b)#define F first#define S secondusingnamespacestd;typedeflonglongll;usingpll=pair<ll,ll>;lldis(plla,pllb){llx=a.F-b.F;lly=a.S-b.S;returnx*x+y*y;}plloperator+(plla,pllb){returnmp(a.F+b.F,a.S+b.S);}intmain(){StarBurstStreamintn;cin>>n;vector<pll>p(n);for(inti=0;i<n;i++){cin>>p[i].F>>p[i].S;}map<pair<pll,ll>,ll>cnt;for(inti=0;i<n;i++){for(intj=i+1;j<n;j++){cnt[mp(p[i]+p[j],dis(p[i],p[j]))]++;}}llans=0;for(autoi:cnt){ans+=i.S*(i.S-1)/2;}cout<<ans<<"\n";return0;}
#include<bits/stdc++.h>#define int long long#define pb push_back#define mk make_pair#define F first#define S second#define ALL(x) x.begin(), x.end()usingnamespacestd;usingpii=pair<int,int>;structNode{intx,y;};constintN=2005;intn;Nodea[N];signedmain(){cin>>n;for(inti=0;i<n;i++){cin>>a[i].x>>a[i].y;}map<pii,int>mp;intans=0;for(inti=0;i<n;i++){for(intj=i+1;j<n;j++){if(a[i].y==a[j].y){intlen=abs(a[j].x-a[i].x);intpoint=(a[i].x+a[j].x);mp[{len,point}]++;}}}intans=0;for(autoit:mp){ans+=it.S*(it.S-1)/2;}cout<<ans<<'\n';}
#include<bits/stdc++.h>#define int long longusingnamespacestd;constintN=2e5+5;chars[N];intn,ans;voidwork(){boolflag=1;cin>>n>>s+1;intx=1,y=1;for(inti=1;s[i];i++){if(s[i]=='R'){x++;}else{y++;}if(s[i]!=s[i-1]&&i!=1)flag=0;}if(flag==1){cout<<n<<'\n';return;}x=n-x,y=n-y;inti=2;ans=1;while(s[i]==s[i-1]){ans++;i++;}for(i;s[i];i++){ans++;if(s[i]=='R'){ans+=y;}else{ans+=x;}if(s[i+1]==0)ans+=(x+1)*(y+1);}cout<<ans<<'\n';}intmain(){intt;cin>>t;while(t--)work();}
#include<bits/stdc++.h>#define int long longusingnamespacestd;constintMAXN=2e5+5;constintmod=998244353;boolrow[MAXN],col[MAXN];intx[MAXN],y[MAXN];intfpow(inta,intb){intres=1;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}returnres;}intmain(){intt;cin>>t;while(t--){memset(row,0,sizeof(row));memset(col,0,sizeof(col));intn,m,k,q;cin>>n>>m>>k>>q;for(inti=1;i<=q;i++){cin>>x[i]>>y[i];}intcnt=0,crow=0,ccol=0;for(inti=q;i>=1;i--){boolok=0;if(crow<n&&ccol<m&&!row[x[i]]){row[x[i]]=1,crow++,ok=1;}if(crow<n&&ccol<m&&!col[y[i]]){col[y[i]]=1,ccol++,ok=1;}if(ok)cnt++;}cout<<fpow(k,cnt)<<'\n';}}