#include<bits/stdc++.h>
using namespace std;
#define int long long
void sol(){
int n, k;
cin >> n >> k;
int a[n], ans = 0;
for(int &i:a) cin >> i;
for(int i = 0; i < n / 2; i++) ans += min(k, abs(a[i] - a[n - i - 1]));
cout << ans << "\n";
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
cin >> t;
while(t--){
sol();
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBpbnQgbG9uZyBsb25nCnZvaWQgc29sKCl7CiAgICBpbnQgbiwgazsKICAgIGNpbiA+PiBuID4+IGs7IAogICAgaW50IGFbbl0sIGFucyA9IDA7CiAgICBmb3IoaW50ICZpOmEpIGNpbiA+PiBpOwogICAgZm9yKGludCBpID0gMDsgaSA8IG4gLyAyOyBpKyspIGFucyArPSBtaW4oaywgYWJzKGFbaV0gLSBhW24gLSBpIC0gMV0pKTsKICAgIGNvdXQgPDwgYW5zIDw8ICJcbiI7CiAKfQpzaWduZWQgbWFpbigpewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKE5VTEwpOwogICAgY291dC50aWUoTlVMTCk7CiAgICBpbnQgdCA9IDE7CiAgICBjaW4gPj4gdDsKICAgIHdoaWxlKHQtLSl7CiAgICAgICAgc29sKCk7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==