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.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.*;
  
  import static java.lang.Math.abs;
  import static java.lang.Math.max;
  import static java.lang.System.*;
  import static java.util.Arrays.sort;
  import static java.util.Collections.replaceAll;
  import static java.util.Collections.reverseOrder;
  
  public class C {
      public static final boolean LOCAL = System.getProperty("ONLINE_JUDGE") == null;
      // public static final boolean LOCAL = System.getProperty("LOCAL")!=null;
      public static final String ANSI_RED = "\u001B[31m";
      public static final String ANSI_RESET = "\u001B[0m";
      static  int M = (int)998244353;
      static final long MM = (long) M * M;
      static final int MAX = Integer.MAX_VALUE;
      static final int MIN = Integer.MIN_VALUE;
      static final int SIZE = (int) 1e9 * 2;
      static ArrayList<Integer> primes = new ArrayList<>();
      //static Scanner sc = new Scanner(System.in);
      static FastReader sc = new FastReader();
      static long startTime;
      static long endTime;
      static boolean[] prime;
      static int[] visited;
      static ArrayList<ArrayList<Integer>> graph;
      static ArrayList<Integer> dfs;
      static boolean isCyclic = false;
  
      public static int swap(int... args) {
          return args[0];
      }
  
      public static void main(String[] args) throws IOException {
          do {
              startTime = currentTimeMillis();
              //setOut(new PrintStream("output"));
              //setIn(new FileInputStream("input"));
  //            int MAX = 2_00_000;
  //            fact = new long[MAX+1];
  //            fact[0]++;
  //            for(int i=1;i<=MAX;i++) {
  //                fact[i] = (fact[i-1] * i)%M;
  //            }
  //            inv = new long[MAX+1];
  //            inv[MAX] = modpow(fact[MAX], M-2, M);
  //            for(int i=MAX-1;i>=0;--i) {
  //                inv[i] = ((i+1)*inv[i+1])%M;
  //            }
  
              int T = sc.nextInt();while (T-- != 0)
              {
                  solve();
  
              }
              out.close();
              endTime = currentTimeMillis();
              long duration = endTime - startTime;
              //out.println(duration);
          } while (LOCAL);
      }
  
      static long[] fact, inv;
      static long nCr(int n, int r) {
          if(r>n || n<0 || r<0) {
              return 0;
          }
          return (((fact[n] * inv[r])%M) * inv[n-r])%M;
      }
      static long modpow(long x, long y, long MOD) {
          if(y==0) {
              return 1;
          }
          if((y&1)==0) {
              return modpow((x*x)%MOD, y>>1, MOD);
          }
          else return (x*modpow(x, y-1, MOD))%MOD;
      }
      static PrintWriter out = new PrintWriter(System.out);
      static long cal(ArrayList<Integer> list,int k){
          long sum = 0;
          for (int i = list.size()-1; i >=0; i-=k) {
              sum+=2L*list.get(i);
          }
          return sum;
      }
      public static void solve(){
  /////////////////////////////////////////////////////////////////////
          int n =sc.nextInt(); int k =sc.nextInt();
          ArrayList<Integer> list = new ArrayList<>();
          ArrayList<Integer> pos = new ArrayList<>();
          ArrayList<Integer> neg = new ArrayList<>();
          for (int i = 0; i < n; i++) {
              int j = sc.nextInt();
              list.add(j);
              if(j>0)
              pos.add(j);
              else
              neg.add(-j);
          }
          pos.add(0); neg.add(0);
          Collections.sort(pos);
          Collections.sort(neg);
         long ans = cal(pos,k) + cal(neg,k);
          System.out.println(ans - Integer.max(pos.get(pos.size()-1),neg.get(neg.size()-1)));
  ///////////////////////////////////////////////////////////////////////
  
      }
      static void dfs(int src) {
          visited[src] = 1;
          for (Integer integer : graph.get(src)) {
              if (visited[integer] != 1) {
                  dfs(integer);
              }
          }
          dfs.add(src);
  
      }
  
      static void detectCycle(int src) {
          visited[src] = 2;
          for (Integer integer : graph.get(src)) {
              if (visited[integer] == 0) {
                  detectCycle(integer);
              } else if (visited[integer] == 2) {
                  isCyclic = true;
                  return;
              }
  
          }
          visited[src] = 1;
      }
  
      static <Array, Target> int count(Array[] array, Target target) {
          int cn = 0;
          for (Array value : array) {
              if (value.equals(target)) cn++;
          }
          return cn;
      }
  
      static int count(String string, char target) {
          int cn = 0;
          for (int i = 0; i < string.length(); i++) {
              if (string.charAt(i) == target) cn++;
          }
          return cn;
      }
  
      static <Array> void revArray(Array[] arr) {
          int n = arr.length;
          for (int i = 0; i < n / 2; i++) {
              Array temp = arr[i];
              arr[i] = arr[n - i - 1];
              arr[n - i - 1] = temp;
          }
  
      }
  
      static <Array> void printArray(Array[] arr) {
          int n = arr.length;
          for (Array array : arr) out.print(array + " ");
          out.println();
      }
  
      static void yes() {
          out.println("YES");
      }
  
      static void no() {
          out.println("NO");
      }
  
      public static boolean isPal(String s) {
          StringBuilder stringBuilder = new StringBuilder(s);
          return s.equals(stringBuilder.reverse().toString());
      }
  
      public static int lowerBound(Integer[] array, int length, int value) {
          int low = -1;
          int hi = length;
          while (low + 1 < hi) {
              int mid = (low + hi) / 2;
              if (array[mid] <= value) {
                  low = mid;
              } else {
                  hi = mid;
              }
          }
          return low;
      }
  
      public static int upperBound(Integer[] array, int length, int value) {
          int low = -1;
          int hi = length;
          while (low + 1 < hi) {
              int mid = (low + hi) >> 1;
              if (array[mid] >= value) {
                  hi = mid;
              } else low = mid;
          }
          return hi;
      }
  
      public static int binarySearch(Integer[] arr, int length, int value) {
          int low = 0;
          int hi = length - 1;
          int ans = -1;
          while (low <= hi) {
              int mid = (low + hi) >> 1;
              if (arr[mid] > value) {
                  hi = mid - 1;
              } else if (arr[mid] < value) {
                  low = mid + 1;
              } else {
                  ans = mid;
                  break;
              }
          }
          return ans;
      }
  
      public static long gcd(long a, long b) {
          return b == 0 ? a : gcd(b, a % b);
      }
  
      public static long lcm(long  a, long b) {
          return a / gcd(a, b) * b;
      }
  
      public static int countDivs(int n) {
          int cn = 0;
          int sqr = (int) Math.sqrt(n);
          for (int i = 1; i <= sqr; ++i) {
              if (n % i == 0) {
                  ++cn;
              }
          }
          cn *= 2;
          if (sqr * sqr == n) cn--;
          return cn;
      }
  
      static void prime(int x) {
          //sieve algorithm. nlog(log(n)).
          prime = new boolean[(x + 1)];
          Arrays.fill(prime, true);
          prime[0] = prime[1] = false;
          for (int i = 2; i * i <= x; i++)
              if (prime[i])
                  for (int j = i * i; j <= x; j += i)
                      prime[j] = false;
      }
  
      static boolean isEven(long x) {
          return x % 2 == 0;
      }
  
      static boolean isPrime(long x) {
          boolean flag = true;
          int sqr = (int) Math.sqrt(x);
          if (x < 2) return false;
          for (int i = 2; i <= sqr; i++) {
              if (x % i == 0) {
                  flag = false;
                  break;
              }
          }
          return flag;
      }
  
      static long factorial(long x) {
          long total = 1;
          for (int i = 2; i <= x; i++)
              total = (total * i) %M;
          return total;
      }
  
      static long power(long x, long n) {
          if (n == 0) {
              return 1;
          }
          long pow = power(x, n / 2L);
          if ((n & 1) == 1) {
              return (x * (pow) * (pow));
          }
          return (pow * pow);
      }
  
      private static <T> String ts(T t) {
          if (t == null) {
              return "null";
          }
          try {
              return ts((Iterable) t);
          } catch (ClassCastException e) {
              if (t instanceof int[]) {
                  String s = Arrays.toString((int[]) t);
                  return "{" + s.substring(1, s.length() - 1) + "}";
              } else if (t instanceof long[]) {
                  String s = Arrays.toString((long[]) t);
                  return "{" + s.substring(1, s.length() - 1) + "}";
              } else if (t instanceof char[]) {
                  String s = Arrays.toString((char[]) t);
                  return "{" + s.substring(1, s.length() - 1) + "}";
              } else if (t instanceof double[]) {
                  String s = Arrays.toString((double[]) t);
                  return "{" + s.substring(1, s.length() - 1) + "}";
              } else if (t instanceof boolean[]) {
                  String s = Arrays.toString((boolean[]) t);
                  return "{" + s.substring(1, s.length() - 1) + "}";
              }
              try {
                  return ts((Object[]) t);
              } catch (ClassCastException e1) {
                  return t.toString();
              }
          }
      }
  
      private static <T> String ts(T[] arr) {
          StringBuilder ret = new StringBuilder();
          ret.append("{");
          boolean first = true;
          for (T t : arr) {
              if (!first) {
                  ret.append(", ");
              }
              first = false;
              ret.append(ts(t));
          }
          ret.append("}");
          return ret.toString();
      }
  
      private static <T> String ts(Iterable<T> iter) {
          StringBuilder ret = new StringBuilder();
          ret.append("{");
          boolean first = true;
          for (T t : iter) {
              if (!first) {
                  ret.append(", ");
              }
              first = false;
              ret.append(ts(t));
          }
          ret.append("}");
          return ret.toString();
      }
  
      public static void dbg(Object... o) {
          if (LOCAL) {
              System.err.print("Line #" + Thread.currentThread().getStackTrace()[2].getLineNumber() + ": [");
              for (int i = 0; i < o.length; i++) {
                  if (i != 0) {
                      System.err.print(", ");
                  }
                  System.err.print(ts(o[i]));
              }
              System.err.println("]");
          }
      }
  
      static 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;
          }
      }
  
      static class Pair implements Comparable<Pair> {
          private final int key;
          private final int value;
  
          public Pair(int key, int value) {
              this.key = key;
              this.value = value;
          }
  
          public int second() {
              return value;
          }
  
          @Override
          public int compareTo(Pair o) {
              return -Integer.compare(key, o.key);
          }
  
          @Override
          public String toString() {
              return "Pair{" + "x=" + key + ", y=" + value + '}';
          }
      }
  
  }