#include <bits/stdc++.h>
#define endl "\n"
#define INT long long int

using namespace std;

char infile[100], outfile[100];

int main() {
    ios::sync_with_stdio(false);
    INT T,A[100100], n, t, i, I,c,d,m,k,m1;
    cin >> T;
    for(I=1;I<=T;I++){
        sprintf(infile, ".%d.in", I);
        freopen(infile, "w", stdout);
        scanf("%lld %lld",&n, &k);
        printf("%lld %lld\n",n, k);
        for(i=0;i<n;i++){
            A[i] = (rand()*rand()*rand())%1000000000ll+1;
            printf("%lld ", A[i]);
        }
        printf("\n");
        sprintf(outfile, ".%d.out", I);
        freopen(outfile, "w", stdout);
        m = m1 = -10000000001ll;
        for(i=0;i<n;i++){
            m = max(m, A[i]);
        }
        for(i=0;i<n;i++){
            A[i] = m - A[i];
            m1 = max(m1,A[i]);
        }
        if(k%2==0){
            for(i=0;i<n;i++) printf("%lld ",m1-A[i]);
        }else{
            for(i=0;i<n;i++) printf("%lld ",A[i]);
        }
        printf("\n");
    }
}
