#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template bool chmax(T& x, const T& y){return (x bool chmin(T& x, const T& y){return (x>y)?(x=y,true):false;}; constexpr ll MOD=998244353; constexpr ll INF=2e18; void solve(){ ll n, m; cin >> n >> m; VI l(n), r(n); REP(i,n) cin >> l[i]; REP(i,n) cin >> r[i]; ll lsum=0, rsum=0; REP(i,n) lsum+=l[i]; REP(i,n) rsum+=r[i]; if(m1){ ll z=(x+y)/2; ll sum=0; REP(i,n){ if(z0) a.push_back(x+1); else a.push_back(x); } } ll ans=0, sum=0; REP(i,n){ ans+=sum*a[n-1-i]; sum+=a[n-1-i]; } cout << ans << endl; } int main(){ int t; cin >> t; while(t--) solve(); return 0; }