description: A total of n depots are located on a number line. Depot i lies at the point x_i for 1 ≤ i ≤ n.
  
  You are a salesman with n bags of goods, attempting to deliver one bag to each of the n depots. You and the n bags are initially at the origin 0. You can carry up to k bags at a time. You must collect the required number of goods from the origin, deliver them to the respective depots, and then return to the origin to collect your next batch of goods.
  
  Calculate the minimum distance you need to cover to deliver all the bags of goods to the depots. You do not have to return to the origin after you have delivered all the bags.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10 500). Description of the test cases follows.
  
  The first line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 2 ⋅ 10^5).
  
  The second line of each test case contains n integers x_1, x_2, …, x_n (-10^9 ≤ x_i ≤ 10^9). It is possible that some depots share the same position.
  
  It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
  
  Output
  
  For each test case, output a single integer denoting the minimum distance you need to cover to deliver all the bags of goods to the depots. 
  
  Example
  
  Input
  
  
  4
  5 1
  1 2 3 4 5
  9 3
  -5 -10 -15 6 5 8 3 7 4
  5 3
  2 2 3 3 3
  4 2
  1000000000 1000000000 1000000000 1000000000
  
  
  Output
  
  
  25
  41
  7
  3000000000
  
  Note
  
  In the first test case, you can carry only one bag at a time. Thus, the following is a solution sequence that gives a minimum travel distance: 0 → 2 → 0 → 4 → 0 → 3 → 0 → 1 → 0 → 5, where each 0 means you go the origin and grab one bag, and each positive integer means you deliver the bag to a depot at this coordinate, giving a total distance of 25 units. It must be noted that there are other sequences that give the same distance.
  
  In the second test case, you can follow the following sequence, among multiple such sequences, to travel minimum distance: 0 → 6 → 8 → 7 → 0 → 5 → 4 → 3 → 0 → (-5) → (-10) → (-15), with distance 41. It can be shown that 41 is the optimal distance for this test case.
solution: import java.io.*;
  import java.util.*;
  
  
  
  import java.math.*;
  import java.math.BigInteger;
  
  
  public final class B
  {    
  	static PrintWriter out = new PrintWriter(System.out); 
  	static StringBuilder ans=new StringBuilder();
  	static FastReader in=new FastReader();
  	static ArrayList<Integer> g[];
  	static long mod=(long) 998244353,INF=Long.MAX_VALUE;
  	static boolean set[];
  	static int par[],col[],D[];
  	static long A[];
  	public static void main(String args[])throws IOException
  	{	
  		/*
  		 * star,rope
  		 */
  		int T=i();
  		outer:while(T-->0)
  		{
  			int N=i(),K=i();			
  			long A[]=inputLong(N);
  			ArrayList<Long> X=new ArrayList<>(),Y=new ArrayList<>();
  			for(long a:A)
  			{
  				if(a<0)
  				{
  					long b=-1L*a;
  					Y.add(b);
  				}
  				else if(a>0)X.add(a);
  			}
  			long s=0;
  			Collections.sort(X);
  			Collections.sort(Y);
  			for(int i=X.size()-1; i>=0; i-=K)
  			{
  				s+=X.get(i);
  				s+=X.get(i);
  			}
  			for(int i=Y.size()-1; i>=0; i-=K)
  			{
  				s+=Y.get(i);
  				s+=Y.get(i);
  			}
  			if(X.size()>0 && Y.size()>0)
  			{
  				s-=Math.max(X.get(X.size()-1), Y.get(Y.size()-1));
  			}
  			else if(X.size()>0)
  			{
  				s-=X.get(X.size()-1);
  			}
  			else if(Y.size()>0)
  			{
  				s-=Y.get(Y.size()-1);
  			}
  			ans.append(s+"\n");
  		}
  		out.println(ans);
  		out.close();
  	}	
  	static int f(int l,int r,long A[],long x)
  	{
  		while(r-l>1)
  		{
  			int m=(l+r)/2;
  			if(A[m]>=x)l=m;
  			else r=m;
  		}
  		return r;
  
  	}
  	static boolean f(long m,long H,long A[],int N)
  	{
  		long s=m;
  		for(int i=0; i<N-1;i++)
  		{
  			s+=Math.min(m, A[i+1]-A[i]);
  		}
  		return s>=H;
  	}
  	static boolean f(int i,int j,long last,boolean win[])
  	{
  		if(i>j)return false;
  		if(A[i]<=last && A[j]<=last)return false;
  		long a=A[i],b=A[j];
  		//System.out.println(a+" "+b);
  		if(a==b)
  		{
  			return win[i] | win[j];
  		}
  		else if(a>b)
  		{
  			boolean f=false;
  			if(b>last)f=!f(i,j-1,b,win);
  			return win[i] | f;
  		}
  		else
  		{
  			boolean f=false;
  			if(a>last)f=!f(i+1,j,a,win);
  			return win[j] | f;
  		}
  	}
  	static long ask(long l,long r)
  	{
  		System.out.println("? "+l+" "+r);
  		return l();
  	}
  	static long f(long N,long M)
  	{
  		long s=0;
  		if(N%3==0)
  		{
  			N/=3;
  			s=N*M;
  		}
  		else
  		{
  			long b=N%3;
  			N/=3;
  			N++;
  			s=N*M;
  			N--;
  			long a=N*M;
  			if(M%3==0)
  			{
  				M/=3;
  				a+=(b*M);
  			}
  			else
  			{
  				M/=3;
  				M++;
  				a+=(b*M);
  			}
  			s=Math.min(s, a);
  		}
  		return s;
  	}
  	static int ask(StringBuilder sb,int a)
  	{
  		System.out.println(sb+""+a);
  		return i();
  	}
  	static void swap(char X[],int i,int j)
  	{
  		char x=X[i];
  		X[i]=X[j];
  		X[j]=x;
  	}
  	static int min(int a,int b,int c)
  	{
  		return Math.min(Math.min(a, b), c);
  	}
  
  
  	static long and(int i,int j)
  	{
  		System.out.println("and "+i+" "+j);
  		return l();
  	}
  	static long or(int i,int j)
  	{
  		System.out.println("or "+i+" "+j);
  		return l();
  	}
  	static int len=0,number=0;
  	static void f(char X[],int i,int num,int l)
  	{
  		if(i==X.length)
  		{
  			if(num==0)return;
  			//update our num
  			if(isPrime(num))return;
  			if(l<len)
  			{
  				len=l;
  				number=num;				
  			}
  			return;
  		}
  		int a=X[i]-'0';
  		f(X,i+1,num*10+a,l+1);
  		f(X,i+1,num,l);
  	}
  	static boolean is_Sorted(int A[])
  	{
  		int N=A.length;
  		for(int i=1; i<=N; i++)if(A[i-1]!=i)return false;
  		return true;
  	}
  	static boolean f(StringBuilder sb,String Y,String order)
  	{
  		StringBuilder res=new StringBuilder(sb.toString());
  		HashSet<Character> set=new HashSet<>();
  		for(char ch:order.toCharArray())
  		{
  			set.add(ch);
  			for(int i=0; i<sb.length(); i++)
  			{
  				char x=sb.charAt(i);
  				if(set.contains(x))continue;
  				res.append(x);
  			}
  		}
  
  		String str=res.toString();
  		return str.equals(Y);
  	}
  	static boolean all_Zero(int f[])
  	{
  		for(int a:f)if(a!=0)return false;
  		return true;
  	}
  	static long form(int a,int l)
  	{
  		long x=0;
  		while(l-->0)
  		{
  			x*=10;
  			x+=a;
  		}
  		return x;
  	}
  	static int count(String X)
  	{
  		HashSet<Integer> set=new HashSet<>();
  		for(char x:X.toCharArray())set.add(x-'0');
  		return set.size();
  	}
  
  	static int f(long K)
  	{
  		long l=0,r=K;
  		while(r-l>1)
  		{
  			long m=(l+r)/2;
  			if(m*m<K)l=m;
  			else r=m;
  		}
  		return (int)l;
  	}
  	//	static void build(int v,int tl,int tr,long A[])
  	//	{
  	//		if(tl==tr)
  	//		{
  	//			seg[v]=A[tl];
  	//		}
  	//		else
  	//		{
  	//			int tm=(tl+tr)/2;
  	//			build(v*2,tl,tm,A);
  	//			build(v*2+1,tm+1,tr,A);
  	//			seg[v]=Math.min(seg[v*2], seg[v*2+1]);
  	//		}
  	//	}
  
  	static int [] sub(int A[],int B[])
  	{
  		int N=A.length;
  		int f[]=new int[N];
  		for(int i=N-1; i>=0; i--)
  		{
  			if(B[i]<A[i])
  			{
  				B[i]+=26;
  				B[i-1]-=1;
  			}
  			f[i]=B[i]-A[i];
  		}
  		for(int i=0; i<N; i++)
  		{
  			if(f[i]%2!=0)f[i+1]+=26;
  			f[i]/=2;
  		}
  		return f;
  	}
  	static int[] f(int  N)
  	{
  		char X[]=in.next().toCharArray();
  		int A[]=new int[N];
  		for(int i=0; i<N; i++)A[i]=X[i]-'a';
  		return A;
  	}
  
  
  
  
  	static int max(int a ,int b,int c,int d)
  	{
  		a=Math.max(a, b);
  		c=Math.max(c,d);
  		return Math.max(a, c);
  	}
  	static int min(int a ,int b,int c,int d)
  	{
  		a=Math.min(a, b);
  		c=Math.min(c,d);
  		return Math.min(a, c);
  	}
  
  
  
  	static HashMap<Integer,Integer> Hash(int A[])
  	{
  		HashMap<Integer,Integer> mp=new HashMap<>();
  		for(int a:A)
  		{
  			int f=mp.getOrDefault(a,0)+1;
  			mp.put(a, f);
  		}
  		return mp;
  	}
  	static long mul(long a, long b)
  	{
  		return ( a %mod * 1L * b%mod )%mod;
  	}
  	static void swap(int A[],int a,int b)
  	{
  		int t=A[a];
  		A[a]=A[b];
  		A[b]=t;
  	}
  
  
  	static int find(int a)
  	{
  		if(par[a]<0)return a;
  		return par[a]=find(par[a]);
  	}
  	static void union(int a,int b)
  	{
  		a=find(a);
  		b=find(b);
  		if(a!=b)
  		{
  			par[a]+=par[b];
  			par[b]=a;
  		}
  	}
  	static boolean isSorted(int A[])
  	{
  		for(int i=1; i<A.length; i++)
  		{
  			if(A[i]<A[i-1])return false;
  		}
  		return true;
  	}
  
  	static boolean isDivisible(StringBuilder X,int i,long num)
  	{
  		long r=0;
  		for(; i<X.length(); i++)
  		{
  			r=r*10+(X.charAt(i)-'0');
  			r=r%num;
  		}
  		return r==0;
  	}    
  
  
  
  	static int lower_Bound(int A[],int low,int high, int x) 
  	{ 
  		if (low > high) 
  			if (x >= A[high]) 
  				return A[high]; 
  
  		int mid = (low + high) / 2; 
  
  		if (A[mid] == x) 
  			return A[mid]; 
  
  		if (mid > 0 && A[mid - 1] <= x && x < A[mid]) 
  			return A[mid - 1]; 
  
  		if (x < A[mid]) 
  			return lower_Bound( A, low, mid - 1, x); 
  
  		return lower_Bound(A, mid + 1, high, x); 
  	} 
  
  	static String f(String A)
  	{
  		String X="";
  		for(int i=A.length()-1; i>=0; i--)
  		{
  			int c=A.charAt(i)-'0';
  			X+=(c+1)%2;
  		}
  		return X;
  	}
  
  	static void sort(long[] a) //check for long
  	{
  		ArrayList<Long> l=new ArrayList<>();
  		for (long i:a) l.add(i);
  		Collections.sort(l);
  		for (int i=0; i<a.length; i++) a[i]=l.get(i);
  	}
  
  	static String swap(String X,int i,int j)
  	{
  		char ch[]=X.toCharArray();
  		char a=ch[i];
  		ch[i]=ch[j];
  		ch[j]=a;
  		return new String(ch);
  	}
  
  	static int sD(long n)  
  	{  
  
  		if (n % 2 == 0 )  
  			return 2;  
  
  		for (int i = 3; i * i <= n; i += 2) {  
  			if (n % i == 0 )  
  				return i;  
  		}  
  
  		return (int)n;  
  	}  
  
  	static void setGraph(int N)
  	{
  		par=new int[N+1];
  		D=new int[N+1];
  		g=new ArrayList[N+1];
  		set=new boolean[N+1];
  		col=new int[N+1];
  		for(int i=0; i<=N; i++)
  		{
  			col[i]=-1;
  			g[i]=new ArrayList<>();		
  			D[i]=Integer.MAX_VALUE;
  		}
  	}
  
  
  
  	static  long pow(long a,long b)
  	{
  		//long mod=1000000007;
  		long pow=1;
  		long x=a;
  		while(b!=0)
  		{
  			if((b&1)!=0)pow=(pow*x)%mod;
  			x=(x*x)%mod;
  			b/=2;
  		}
  		return pow;
  	}
  
  	static long toggleBits(long x)//one's complement || Toggle bits
  	{
  		int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;
  
  		return ((1<<n)-1)^x;
  	}
  
  	static int countBits(long a)
  	{
  		return (int)(Math.log(a)/Math.log(2)+1);
  	}
  
  	static long fact(long N)
  	{ 
  		long n=2; 
  		if(N<=1)return 1;
  		else
  		{
  			for(int i=3; i<=N; i++)n=(n*i)%mod;
  		}
  		return n;
  	}
  
  	static int kadane(int A[])
  	{
  		int lsum=A[0],gsum=A[0];
  		for(int i=1; i<A.length; i++)
  		{
  			lsum=Math.max(lsum+A[i],A[i]);
  			gsum=Math.max(gsum,lsum);
  		}
  		return gsum;
  	}
  
  	static void sort(int[] a) {
  		ArrayList<Integer> l=new ArrayList<>();
  		for (int i:a) l.add(i);
  		Collections.sort(l);
  		for (int i=0; i<a.length; i++) a[i]=l.get(i);
  	}
  
  	static boolean isPrime(long N)
  	{
  		if (N<=1)  return false; 
  		if (N<=3)  return true; 
  		if (N%2 == 0 || N%3 == 0) return false; 
  		for (int i=5; i*i<=N; i=i+6) 
  			if (N%i == 0 || N%(i+2) == 0) 
  				return false; 
  		return true; 
  	}
  	static void print(char A[])
  	{
  		for(char c:A)System.out.print(c+" ");
  		System.out.println();
  	}
  	static void print(boolean A[])
  	{
  		for(boolean c:A)System.out.print(c+" ");
  		System.out.println();
  	}
  	static void print(int A[])
  	{
  		for(int a:A)System.out.print(a+" ");
  		System.out.println();	
  	}
  	static void print(long A[])
  	{
  		for(long i:A)System.out.print(i+ " ");
  		System.out.println();
  
  	}
  	static void print(boolean A[][])
  	{
  		for(boolean a[]:A)print(a);
  	}
  	static void print(long A[][])
  	{
  		for(long a[]:A)print(a);
  	}
  	static void print(int A[][])
  	{
  		for(int a[]:A)print(a);
  	}
  	static void print(ArrayList<Integer> A)
  	{
  		for(int a:A)System.out.print(a+" ");
  		System.out.println();
  	}
  
  	static int i()
  	{
  		return in.nextInt();
  	}
  
  	static long l()
  	{
  		return in.nextLong();
  	}
  
  	static int[] input(int N){
  		int A[]=new int[N];
  		for(int i=0; i<N; i++)
  		{
  			A[i]=in.nextInt();
  		}
  		return A;
  	}
  
  	static long[] inputLong(int N)     {
  		long A[]=new long[N];
  		for(int i=0; i<A.length; i++)A[i]=in.nextLong();
  		return A;
  	}
  
  	static long GCD(long a,long b) 
  	{
  		if(b==0)
  		{
  			return a;
  		}
  		else return GCD(b,a%b );
  	}
  
  }
  class player implements Comparable<player>
  {
  	int index;
  	long a,b;
  	player(long a,long b,int i)
  	{
  		this.a=a;
  		this.b=b;
  		index=i;
  	}
  	public int compareTo(player x)
  	{
  		long a=this.a,b=x.a;
  		if(a>b)return 1;
  		else if(b>a)return -1;
  		return 0;
  	}
  }
  
  
  //Code For FastReader
  //Code For FastReader
  //Code For FastReader
  //Code For FastReader
  class FastReader
  {
  	BufferedReader br;
  	StringTokenizer st;
  	public FastReader()
  	{
  		br=new BufferedReader(new InputStreamReader(System.in));
  	}
  
  	String next()
  	{
  		while(st==null || !st.hasMoreElements())
  		{
  			try
  			{
  				st=new StringTokenizer(br.readLine());
  			}
  			catch(IOException e)
  			{
  				e.printStackTrace();
  			}
  		}
  		return st.nextToken();
  	}
  
  	int nextInt()
  	{
  		return Integer.parseInt(next());
  	}
  
  	long nextLong()
  	{
  		return Long.parseLong(next());
  	}
  
  	double nextDouble()
  	{
  		return Double.parseDouble(next());
  	}
  
  	String nextLine()
  	{
  		String str="";
  		try
  		{
  			str=br.readLine();
  		}
  		catch (IOException e)
  		{
  			e.printStackTrace();
  		}
  		return str;
  	}
  
  }