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.util.*;
  import java.io.*;
  import java.math.*;
  import java.lang.*;
  
  public class c {
      
      // static int mod = 998244353;
      static int mod = 1000000007;
  
      public static class Reader {
          final private int BUFFER_SIZE = 1 << 16;
          private DataInputStream din;
          private byte[] buffer;
          private int bufferPointer, bytesRead;
   
          public Reader()
          {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public Reader(String file_name) throws IOException
          {
              din = new DataInputStream(
                  new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public String readLine() throws IOException
          {
              byte[] buf = new byte[64]; // line length
              int cnt = 0, c;
              while ((c = read()) != -1) {
                  if (c == '\n') {
                      if (cnt != 0) {
                          break;
                      }
                      else {
                          continue;
                      }
                  }
                  buf[cnt++] = (byte)c;
              }
              return new String(buf, 0, cnt);
          }
   
          public int nextInt() throws IOException
          {
              int ret = 0;
              byte c = read();
              while (c <= ' ') {
                  c = read();
              }
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (neg)
                  return -ret;
              return ret;
          }
   
          public long nextLong() throws IOException
          {
              long ret = 0;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg)
                  return -ret;
              return ret;
          }
   
          public double nextDouble() throws IOException
          {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
   
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (c == '.') {
                  while ((c = read()) >= '0' && c <= '9') {
                      ret += (c - '0') / (div *= 10);
                  }
              }
   
              if (neg)
                  return -ret;
              return ret;
          }
   
          private void fillBuffer() throws IOException
          {
              bytesRead = din.read(buffer, bufferPointer = 0,
                                   BUFFER_SIZE);
              if (bytesRead == -1)
                  buffer[0] = -1;
          }
   
          private byte read() throws IOException
          {
              if (bufferPointer == bytesRead)
                  fillBuffer();
              return buffer[bufferPointer++];
          }
   
          public void close() throws IOException
          {
              if (din == null)
                  return;
              din.close();
          }
      }
  
      public static void main(String[] args) throws Exception {
          Reader scn = new Reader();
          PrintWriter pw = new PrintWriter(System.out);
          int t = scn.nextInt();
          outer : while(t-->0){
              int n = scn.nextInt();
              int k = scn.nextInt();
              ArrayList<Long> positive = new ArrayList<>();
              ArrayList<Long> negative = new ArrayList<>();
              long[] arr = new long[n];
              for(int i=0; i<n; i++){
                  arr[i] = scn.nextLong();
                  if(arr[i] > 0){
                      positive.add(arr[i]);
                  }else{
                      negative.add(Math.abs(arr[i]));
                  }
              }
              Collections.sort(positive);
              Collections.sort(negative);
              if(positive.size() > 0 && negative.size() > 0){
                  long dis = 0L;
                  int i = positive.size()-1;
                  while(i >= 0){
                      dis += positive.get(i);
                      i -= k;
                  }
                  int j = negative.size()-1;
                  while(j >= 0){
                      dis += negative.get(j);
                      j -= k;
                  }
                  dis *= 2L;
                  dis -= Math.max(positive.get(positive.size()-1), negative.get(negative.size()-1));
                  pw.println(dis);
                  continue outer;
              }else if(positive.size() > 0){
                  long dis = 0L;
                  int i = positive.size()-1;
                  while(i >= 0){
                      dis += positive.get(i);
                      i -= k;
                  }
                  dis *= 2L;
                  dis -= positive.get(positive.size()-1);
                  pw.println(dis);
                  continue outer;
              }else if(negative.size() > 0){
                  long dis = 0L;
                  int i = negative.size()-1;
                  while(i >= 0){
                      dis += negative.get(i);
                      i -= k;
                  }
                  dis *= 2L;
                  dis -= negative.get(negative.size()-1);
                  pw.println(dis);
                  continue outer;
              }
          }
          pw.close();
      }
  
      public static class Pair{
          int x;
          int y;
  
          Pair(int x, int y){
              this.x = x;
              this.y = y;
          }
      }
  
      private static void sort(int[] arr) {
          List<Integer> list = new ArrayList<>();
          for (int i=0; i<arr.length; i++){
              list.add(arr[i]);
          }
          Collections.sort(list); // collections.sort uses nlogn in backend
          for (int i = 0; i < arr.length; i++){
              arr[i] = list.get(i);
          }
      }
  
      private static void sort(long[] arr) {
          List<Long> list = new ArrayList<>();
          for(int i=0; i<arr.length; i++){
              list.add(arr[i]);
          }
          Collections.sort(list); // collections.sort uses nlogn in backend
          for (int i = 0; i < arr.length; i++){
              arr[i] = list.get(i);
          }
      }
  
      // private static void sort(Pair[] arr) {
      //     List<Pair> list = new ArrayList<>();
      //     for(int i=0; i<arr.length; i++){
      //         list.add(arr[i]);
      //     }
      //     Collections.sort(list); // collections.sort uses nlogn in backend
      //     for (int i = 0; i < arr.length; i++){
      //         arr[i] = list.get(i);
      //     }
      // }
  
      private static void reverseSort(int[] arr){
          List<Integer> list = new ArrayList<>();
          for (int i=0; i<arr.length; i++){
              list.add(arr[i]);
          }
          Collections.sort(list, Collections.reverseOrder()); // collections.sort uses nlogn in backend
          for (int i = 0; i < arr.length; i++){
              arr[i] = list.get(i);
          }
      }
  
      private static void reverseSort(long[] arr){
          List<Long> list = new ArrayList<>();
          for (int i=0; i<arr.length; i++){
              list.add(arr[i]);
          }
          Collections.sort(list, Collections.reverseOrder()); // collections.sort uses nlogn in backend
          for (int i = 0; i < arr.length; i++){
              arr[i] = list.get(i);
          }
      }
  
      private static void reverseSort(ArrayList<Integer> list){
          Collections.sort(list, Collections.reverseOrder());
      }
  
      private static int lowerBound(int[] arr, int x){
          int n = arr.length, si = 0, ei = n - 1;
          while(si <= ei){
              int mid = si + (ei - si)/2;
              if(arr[mid] == x){
                  if(mid-1 >= 0 && arr[mid-1] == arr[mid]){
                      ei = mid-1;
                  }else{
                      return mid;
                  }
              }else if(arr[mid] > x){
                  ei = mid - 1; 
              }else{
                  si = mid+1;
              }
          }
          return si; 
      }
  
      private static int upperBound(int[] arr, int x){
          int n = arr.length, si = 0, ei = n - 1;
          while(si <= ei){
              int mid = si + (ei - si)/2;
              if(arr[mid] == x){
                  if(mid+1 < n && arr[mid+1] == arr[mid]){
                      si = mid+1;
                  }else{
                      return mid + 1;
                  }
              }else if(arr[mid] > x){
                  ei = mid - 1; 
              }else{
                  si = mid+1;
              }
          }
          return si; 
      }
  
      private static int upperBound(ArrayList<Integer> list, int x){
          int n = list.size(), si = 0, ei = n - 1;
          while(si <= ei){
              int mid = si + (ei - si)/2;
              if(list.get(mid) == x){
                  if(mid+1 < n && list.get(mid+1) == list.get(mid)){
                      si = mid+1;
                  }else{
                      return mid + 1;
                  }
              }else if(list.get(mid) > x){
                  ei = mid - 1; 
              }else{
                  si = mid+1;
              }
          }
          return si; 
      }
  
      // (x^y)%p in O(logy)
      private static long power(long x, long y){
          long res = 1; 
          x = x % mod;
          while(y > 0){
              if ((y & 1) == 1){
                  res = (res * x) % mod;
              }
              y = y >> 1; 
              x = (x * x) % mod;
          }
          return res;
      }
  
      public static boolean nextPermutation(int[] arr) {
          if(arr == null || arr.length <= 1){
              return false;
          }
          
          int last = arr.length-2;
          while(last >= 0){
              if(arr[last] < arr[last+1]){
                  break;
              }
              last--;
          }
  
          if (last < 0){
                return false;
          }
          
          if(last >= 0){
              int nextGreater = arr.length-1;
              for(int i=arr.length-1; i>last; i--){
                  if(arr[i] > arr[last]){
                      nextGreater = i;
                      break;
                  }
              }
              swap(arr, last, nextGreater);
          }
          
          reverse(arr, last+1, arr.length-1);
          return true;
      }
      
      private static void swap(int[] arr, int i, int j){
          int temp = arr[i];
          arr[i] = arr[j];
          arr[j] = temp;
      }
      
      private static void reverse(int[] arr, int i, int j){
          while(i < j){
              swap(arr, i++, j--);
          }
      }
  
      private static String reverseStr(String s){
          StringBuilder sb = new StringBuilder(s);
          return sb.reverse().toString();
      }
  
      // TC- O(logmax(a,b))
      private static int gcd(int a, int b) {
          if(a == 0){
              return b;
          }
          return gcd(b%a, a);
      }
  
      private static long gcd(long a, long b) {
          if(a == 0L){
              return b;
          }
          return gcd(b%a, a);
      }
  
      private static long lcm(long a, long b) {
          return a / gcd(a, b) * b;
      }
  
      // TC- O(logmax(a,b))
      private static int lcm(int a, int b) {
          return a / gcd(a, b) * b;
      }
  
      private static long inv(long x){
          return power(x, mod - 2);
      }
  
      private static long summation(long n){
          return (n * (n + 1L)) >> 1;
      } 
  }