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.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  import java.util.*;
  import java.util.concurrent.ThreadLocalRandom;
  
  //import com.sun.tools.sjavac.server.SysInfo;
  
  
  public class a729 {
  
  	public static void main(String[] args) throws IOException {
         BufferedWriter out = new BufferedWriter(
  	            new OutputStreamWriter(System.out));
  		BufferedReader br = new BufferedReader(
  		        new InputStreamReader(System.in));
  		PrintWriter pt = new PrintWriter(System.out);
  		FastReader sc = new FastReader();
  
  		int t = sc.nextInt();
  		for(int o = 0 ; o<t;o++){
  			int n = sc.nextInt();
  			int k = sc.nextInt();
  			
  			long[]arr = new long[n];
  			for(int i = 0;i<n;i++){
  				arr[i] = sc.nextLong();
              }
  			ArrayList<Long> pos = new ArrayList<Long>();
  			ArrayList<Long> neg = new ArrayList<Long>();
  			
  			for(int i = 0 ; i<n;i++) {
  				if(arr[i]>=0) {
  					pos.add(arr[i]);
  				}else {
  					neg.add(-arr[i]);
  				}
  			}
  			
  			Collections.sort(pos,Collections.reverseOrder());
  			Collections.sort(neg,Collections.reverseOrder());
  			
  //			int a = pos.get(pos.size()-1);
  //			
  //			int b = neg.get(0);
  //			
  			
  			int p = pos.size();
  			int m = neg.size();
  			long ans = 0;
  			
  			int i = 0;
  			for( i = 0 ; i<p;i+=k) {
  				ans+= pos.get(i)*2;
  //			System.out.println(ans);
  			
  			
  			}
  			
  //			if(p>0 && i>p) {
  //				ans+= pos.get(p-1);
  //			}
  			
  //			System.out.println(ans);
  			int j = 0;
  			for( j = 0 ; j<m;j+=k) {
  				ans+= (long)Math.abs(neg.get(j)*2);
  				if(j+k>m-1) {
  					break;
  				}
  			}
  //			if(m> 0 && j>m) {
  //				ans += (long)Math.abs(neg.get(m-1)*2);
  ////			System.out.println(ans);
  //			}
  			
  			long v1 = Integer.MIN_VALUE;
  			long v2 = Integer.MIN_VALUE;
  			if(p>0) {
  				v1 = pos.get(0);
  			}
  			if(m>0) {
  				v2 = neg.get(0);
  			}
  //			System.out.println(ans);
  		ans-= Math.max(v1, v2);
  		System.out.println(ans);
  		}
  	}
  //------------------------------------------------------------------------------------------------------------------------------------------------
  		
  	public static void build(int [][] seg,char []arr,int idx, int lo , int hi) {
  	if(lo == hi) {
  //		seg[idx] = arr[lo];
  		seg[idx][(int)arr[lo]-'a'] = 1;
  		
  		return;
  	}
  	int mid = (lo + hi)/2;
  build(seg,arr,2*idx+1, lo, mid);
  build(seg,arr,idx*2+2, mid +1, hi);
  //seg[idx] = Math.min(seg[2*idx+1],seg[2*idx+2]);
  for(int i = 0 ; i<27;i++) {
  	seg[idx][i] = seg[2*idx+1][i] + seg[2*idx + 2][i];
  }
  	}
  //for f/inding minimum in range 
  public static void query(int[][]seg,int[]ans,int idx , int lo , int hi , int l , int r) {
  	if(lo>=l && hi<=r) {
  		for(int i = 0 ; i<27;i++) {
  			ans[i]+= seg[idx][i];
  		}
  		return ;
  	}
  if(hi<l || lo>r) {
  	return;
  }
  int mid = (lo + hi)/2;
  query(seg,ans,idx*2 +1, lo, mid, l, r);
  query(seg,ans,idx*2 + 2, mid + 1, hi, l, r);
  //return Math.min(left, right);
  }
  //// for sum
  //
  public static void update(int[][]seg,char[]arr,int idx, int lo , int hi , int node , char val) {
  if(lo == hi) {
  //	seg[idx] += val;
  seg[idx][val-'a']++;
  seg[idx][arr[node]-'a']--;
  
  }else {
  int mid = (lo + hi )/2;
  if(node<=mid && node>=lo) {
  update(seg,arr, idx * 2 +1, lo, mid, node, val);
  }else {
  update(seg,arr, idx*2 + 2, mid + 1, hi, node, val);
  }
  //seg[idx] = seg[idx*2 + 1] + seg[idx*2 + 2];
  for(int i = 0 ; i<27;i++) {
  	seg[idx][i] = seg[2*idx+1][i] + seg[2*idx + 2][i];
  }
  }
  
  }
  	
  	
  	
  	
  	
  	
  	public static int lower_bound(int array[], int low, int high, int key){
  	// Base Case
  	if (low > high) {
  	return low;
  	}
  
  	// Find the middle index
  	int mid = low + (high - low) / 2;
  
  	// If key is lesser than or equal to
  	// array[mid] , then search
  	// in left subarray
  	if (key <= array[mid]) {
  
  	return lower_bound(array, low,
  	            mid - 1, key);
  	}
  
  	// If key is greater than array[mid],
  	// then find in right subarray
  	return lower_bound(array, mid + 1, high,
  	        key);
  	}
  	
  	public static int upper_bound(int arr[], int low,
              int high, int key){
  // Base Case
  if (low > high || low == arr.length)
  return low;
  
  // Find the value of middle index
  int mid = low + (high - low) / 2;
  
  // If key is greater than or equal
  // to array[mid], then find in
  // right subarray
  if (key >= arr[mid]) {
  return upper_bound(arr, mid + 1, high,
                  key);
  }
  
  // If key is less than array[mid],
  // then find in left subarray
  return upper_bound(arr, low, mid - 1,
              key);
  }
  
  //	-----------------------------------------------------------------------------------------------------------------------------------------------
  	public static int gcd(int a, int b){
          if (a == 0)
              return b;
          return gcd(b % a, a);
      }
  //--------------------------------------------------------------------------------------------------------------------------------------------------------
  	public static long modInverse(long a, long m){
          long m0 = m;
          long y = 0, x = 1;
   
          if (m == 1)
              return 0;
   
          while (a > 1) {
              // q is quotient
              long q = a / m;
   
              long t = m;
   
              // m is remainder now, process
              // same as Euclid's algo
              m = a % m;
              a = t;
              t = y;
   
              // Update x and y
              y = x - q * y;
              x = t;
          }
   
          // Make x positive
          if (x < 0)
              x += m0;
   
          return x;
      }
  
  		
  
  //-----------------------------------------------------------------------------------------------------------------------------------
  
  	//segment tree
  	//for finding minimum in range 
  //	public static void build(int [] seg,int []arr,int idx, int lo , int hi) {
  //		if(lo == hi) {
  //			seg[idx] = arr[lo];
  //			return;
  //		}
  //		int mid = (lo + hi)/2;
  //	build(seg,arr,2*idx+1, lo, mid);
  //	build(seg,arr,idx*2+2, mid +1, hi);
  //	seg[idx] = Math.min(seg[2*idx+1],seg[2*idx+2]);
  //	}
  ////for finding minimum in range 
  //public static int query(int[]seg,int idx , int lo , int hi , int l , int r) {
  //		if(lo>=l && hi<=r) {
  //			return seg[idx];
  //		}
  //	if(hi<l || lo>r) {
  //		return Integer.MAX_VALUE;
  //	}
  //	int mid = (lo + hi)/2;
  //	int left = query(seg,idx*2 +1, lo, mid, l, r);
  //	int right = query(seg,idx*2 + 2, mid + 1, hi, l, r);
  //	return Math.min(left, right);
  //}
  //	// for sum
  //
  //public static void update(int[]seg,int idx, int lo , int hi , int node , int val) {
  //	if(lo == hi) {
  //		seg[idx] += val;
  //	}else {
  //int mid = (lo + hi )/2;
  //if(node<=mid && node>=lo) {
  //	update(seg, idx * 2 +1, lo, mid, node, val);
  //}else {
  //	update(seg, idx*2 + 2, mid + 1, hi, node, val);
  //}
  //seg[idx] = seg[idx*2 + 1] + seg[idx*2 + 2];
  //
  //}
  
  //}
  //---------------------------------------------------------------------------------------------------------------------------------------
  
  
  	static void shuffleArray(int[] ar)
  	  {
  	    // If running on Java 6 or older, use `new Random()` on RHS here
  	    Random rnd = ThreadLocalRandom.current();
  	    for (int i = ar.length - 1; i > 0; i--)
  	    {
  	      int index = rnd.nextInt(i + 1);
  	      // Simple swap
  	      int a = ar[index];
  	      ar[index] = ar[i];
  	      ar[i] = a;
  	    }
  	  }
  //-----------------------------------------------------------------------------------------------------------------------------------------------------------
  
  }
  
  
  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;
      }
  }
  //------------------------------------------------------------------------------------------------------------------------------------------------------------
  class SegmentTree{
  	
  int n;
  	public SegmentTree(int[] arr,int n) {
  		this.arr = arr;
  		this.n = n;
  	}
  	int[] arr = new int[n];
  //	int n = arr.length;
  	int[] seg = new int[4*n];
  	void build(int idx, int lo , int hi) {
  		if(lo == hi) {
  			seg[idx] = arr[lo];
  			return;
  		}
  		int mid = (lo + hi)/2;
  	build(2*idx+1, lo, mid);
  	build(idx*2+2, mid +1, hi);
  	seg[idx] = Math.min(seg[2*idx+1],seg[2*idx+2]);
  	}
  	int query(int idx , int lo , int hi , int l , int r) {
  		if(lo<=l && hi>=r) {
  			return seg[idx];
  		}
  	if(hi<l || lo>r) {
  		return Integer.MAX_VALUE;
  	}
  	int mid = (lo + hi)/2;
  	int left = query(idx*2 +1, lo, mid, l, r);
  	int right = query(idx*2 + 2, mid + 1, hi, l, r);
  	return Math.min(left, right);
  	}
  	
  	
  }
  //-----------------------------------------------------------------------------------------------------------------------------------------------------------
  class coup{
  	int a , b;
  	public coup(int a , int b) {
  		this.a = a;
  		this.b = b;
  	}
  }
  
  class trip{
  	int a , b, c;
  	public trip(int a , int b, int c) {
  		this.a = a;
  		this.b = b;
  		this.c = c;
  	}
  }
  //---------------------------------------------------------------------------------------------------------------------------------------------------------------
  