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.*;
  
  public class Main {
      // ArrayList<Integer> al = new ArrayList<>();
      // ArrayList<Pair<Integer, Integer>> al = new ArrayList<>();
      // Set<Integer> set = new TreeSet<>();
      // Pair<Integer, Integer> pair;
      // Map<Integer, Integer> map = new HashMap<>();
      // LinkedList<Integer> ll = new LinkedList<>();
      // for(Map.Entry<Integer,Integer> e:map.entrySet())pn(e.getKey()+"
      // "+e.getValue());
      // map.put(key,map.getOrDefault(key,0)+1);
  
      // *********************** Code Begins From Here*************************
      public static void solve() {
          int n = c.i(), k = c.i();
          long a[] = c.longArray(n);
          ArrayList<Long> ne = new ArrayList<>();
          ArrayList<Long> po = new ArrayList<>();
          for (long e : a)
              if (e < 0)
                  ne.add(e);
              else
                  po.add(e);
          Collections.sort(ne);
          Collections.sort(po);
          // pn(ne + " " + po);
          long sum1 = 0, sum2 = 0;
          if (!po.isEmpty()) {
              int i = po.size() - 1;
              sum1 += po.get(i);
              sum2 += 2 * po.get(i);
              i -= k;
              while (i >= 0) {
                  sum1 += 2 * po.get(i);
                  sum2 += 2 * po.get(i);
                  i -= k;
              }
          }
          if (!ne.isEmpty()) {
              int i = 0;
              sum1 += 2 * -ne.get(i);
              sum2 += -ne.get(i);
              i = k;
              while (i < ne.size()) {
                  sum1 += 2 * -ne.get(i);
                  sum2 += 2 * -ne.get(i);
                  i += k;
              }
          }
          pn(min(sum1, sum2));
      }
  
      public static void main(String[] args) throws FileNotFoundException {
          c = new FastScanner();
          pw = new PrintWriter(System.out);
          int tc = 1;
          tc = c.i();
          long start = System.currentTimeMillis();
          for (int t = 0; t < tc; t++) {
              // p("Case #" + (t + 1) + ": ");
              solve();
          }
          long end = System.currentTimeMillis();
          if (System.getProperty("os.name").equals("Mac OS X")) {
              pn("The Program takes " + (end - start) + "ms");
          }
          pw.close();
      }
  
      // math util
      private static int lower(int a[], int x) {
          int l = 0, r = a.length - 1, mid, ans = -1;
          while (l <= r) {
              mid = l + ((r - l) >> 1);
              if (a[mid] <= x) {
                  ans = max(ans, mid);
                  l = mid + 1;
              } else
                  r = mid - 1;
          }
          return ans;
      }
  
      private static int upper(int a[], int x) {
          int l = 0, r = a.length - 1, mid, ans = -1;
          while (l <= r) {
              mid = l + ((r - l) >> 1);
              if (a[mid] >= x) {
                  ans = mid;
                  r = mid - 1;
              } else
                  l = mid + 1;
              // pn(l + " " + mid + " " + r);
          }
          return ans;
      }
  
      private static int cei(double d) {
          return (int) Math.ceil(d);
      }
  
      private static long ceil(double d) {
          return (long) Math.ceil(d);
      }
  
      private static int gcd(int a, int b) {
          return b == 0 ? a : gcd(b, a % b);
      }
  
      private static long gcd(long a, long b) {
          return b == 0 ? a : gcd(b, a % b);
      }
  
      private static int abs(int a, int b) {
          return (int) Math.abs(a - b);
      }
  
      private static int abs(int a) {
          return (int) Math.abs(a);
      }
  
      private static long abs(long a) {
          return (long) Math.abs(a);
      }
  
      private static long abs(long a, long b) {
          return (long) Math.abs(a - b);
      }
  
      private static int max(int a, int b) {
          if (a > b) {
              return a;
          } else {
              return b;
          }
      }
  
      private static int min(int a, int b) {
          if (a > b) {
              return b;
          } else {
              return a;
          }
      }
  
      private static long max(long a, long b) {
          if (a > b) {
              return a;
          } else {
              return b;
          }
      }
  
      private static long min(long a, long b) {
          if (a > b) {
              return b;
          } else {
              return a;
          }
      }
  
      private static int pow(int base, int exp) {
          int result = 1;
          while (exp != 0) {
              if ((exp & 1) == 1)
                  result *= base;
              exp >>= 1;
              base *= base;
          }
          return result;
      }
  
      private static long powerMod(long base, long exp, long mod) {
          long result = 1;
          base %= mod;
          while (exp > 0) {
              if ((exp & 1) != 0)
                  result = (result * base) % mod;
              exp >>= 1;
              base = base * base % mod;
          }
          return result < 0 ? result + mod : result;
      }
  
      private static long addMod(long a, long b, long mod) {
          return (a % mod + b % mod) % mod;
      }
  
      private static long subMod(long a, long b, long mod) {
          return (a % mod - b % mod) % mod;
      }
  
      private static long mulMod(long a, long b, long mod) {
          return ((a % mod) * (b % mod)) % mod;
      }
  
      private static long pow(long base, long exp) {
          long result = 1;
          while (exp != 0) {
              if ((exp & 1) == 1)
                  result = result * base;
              exp >>= 1;
              base *= base;
          }
          return result;
      }
  
      // array util
      private static void sortList(ArrayList<Integer> al) {
          Collections.sort(al);
      }
  
      private static void sortListP(ArrayList<Pair<Integer, Integer>> al) {
          Collections.sort(al);
      }
  
      private static void sort(int[] a) {
          ArrayList<Integer> al = new ArrayList<>();
          for (int e : a)
              al.add(e);
          sortList(al);
          int i = 0;
          for (int e : al)
              a[i++] = e;
      }
  
      private static void sort(char[] a) {
          ArrayList<Character> al = new ArrayList<>();
          for (char e : a)
              al.add(e);
          Collections.sort(al);
          int i = 0;
          for (char e : al)
              a[i++] = e;
      }
  
      private static void sort(long[] a) {
          ArrayList<Long> al = new ArrayList<>();
          for (long e : a)
              al.add(e);
          Collections.sort(al);
          int i = 0;
          for (long e : al)
              a[i++] = e;
      }
  
      private static int[] copy(int[] a) {
          int[] ans = new int[a.length];
          for (int i = 0; i < a.length; ++i)
              ans[i] = a[i];
          return ans;
      }
  
      private static char[] copy(char[] a) {
          char[] ans = new char[a.length];
          for (int i = 0; i < a.length; ++i)
              ans[i] = a[i];
          return ans;
      }
  
      private static long[] copy(long[] a) {
          long[] ans = new long[a.length];
          for (int i = 0; i < a.length; ++i)
              ans[i] = a[i];
          return ans;
      }
      // output
  
      private static void pn(Object o) {
          pw.println(o);
      }
  
      private static void p(Object o) {
          pw.print(o);
      }
  
      private static void pry() {
          pn("Yes");
      }
  
      private static void pY() {
          pn("YES");
      }
  
      private static void prn() {
          pn("No");
      }
  
      private static void pN() {
          pn("NO");
      }
  
      private static void flush() {
          pw.flush();
      }
  
      private static void watch(int[] a) {
          for (int e : a)
              p(e + " ");
          pn("");
      }
  
      private static void watch(long[] a) {
          for (long e : a)
              p(e + " ");
          pn("");
      }
  
      private static void watch(char[] a) {
          for (char e : a)
              p(e);
          pn("");
      }
  
      private static void watchList(ArrayList<Integer> al) {
          for (int e : al)
              p(e + " ");
          pn("");
      }
  
      private static Set<Integer> putSet(int[] a) {
          Set<Integer> set = new TreeSet<>();
          for (int e : a)
              set.add(e);
          return set;
      }
  
      private static boolean[] sieve(int n) {
          boolean[] isPrime = new boolean[n + 1];
          Arrays.fill(isPrime, true);
          isPrime[0] = false;
          isPrime[1] = false;
          for (int i = 2; i * i <= n; i++) {
              for (int j = i * i; j <= n; j += i) {
                  isPrime[j] = false;
              }
          }
          return isPrime;
      }
  
      private static class Pair<U, V> implements Comparable<Pair<U, V>> {
          public final U first;
          public V second;
  
          public <U, V> Pair<U, V> makePair(U first, V second) {
              return new Pair<U, V>(first, second);
          }
  
          public Pair(U first, V second) {
              this.first = first;
              this.second = second;
          }
  
          @Override
          public boolean equals(Object o) {
              if (this == o) {
                  return true;
              }
              if (o == null || getClass() != o.getClass()) {
                  return false;
              }
  
              Pair pair = (Pair) o;
  
              return !(first != null ? !first.equals(pair.first) : pair.first != null)
                      && !(second != null ? !second.equals(pair.second) : pair.second != null);
          }
  
          @Override
          public int hashCode() {
              int result = first != null ? first.hashCode() : 0;
              result = 31 * result + (second != null ? second.hashCode() : 0);
              return result;
          }
  
          public Pair<V, U> swap() {
              return makePair(second, first);
          }
  
          @Override
          public String toString() {
              return "(" + first + "," + second + ")";
          }
  
          @SuppressWarnings({ "unchecked" })
          public int compareTo(Pair<U, V> o) {
              int value = ((Comparable<U>) first).compareTo(o.first);
              if (value != 0) {
                  return value;
              }
              return ((Comparable<V>) second).compareTo(o.second);
          }
      }
  
      private static class FastScanner {
          BufferedReader br;
          StringTokenizer st;
  
          public FastScanner() throws FileNotFoundException {
  
              if (System.getProperty("os.name").equals("Mac OS X")) {
                  // Input is a file
                  br = new BufferedReader(new FileReader("input.txt"));
  
                  // PrintWriter class prints formatted representations
                  // of objects to a text-output stream.
                  PrintStream pw = new PrintStream(new FileOutputStream("output.txt"));
                  System.setOut(pw);
              } else {
                  // Input is System.in
                  br = new BufferedReader(new InputStreamReader(System.in), 32768);
                  st = null;
              }
  
          }
  
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int i() {
              return Integer.parseInt(next());
          }
  
          int[] intArray(int n) {
              int[] ret = new int[n];
              for (int i = 0; i < n; i++)
                  ret[i] = i();
              return ret;
          }
  
          ArrayList<Integer> intList(int n) {
              ArrayList<Integer> al = new ArrayList<>();
              for (int i = 0; i < n; i++)
                  al.add(i());
              return al;
          }
  
          long l() {
              return Long.parseLong(next());
          }
  
          long[] longArray(int n) {
              long[] ret = new long[n];
              for (int i = 0; i < n; i++)
                  ret[i] = l();
              return ret;
          }
  
          ArrayList<Long> longList(int n) {
              ArrayList<Long> al = new ArrayList<>();
              for (int i = 0; i < n; i++)
                  al.add(l());
              return al;
          }
  
          double d() {
              return Double.parseDouble(next());
          }
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
  
      private static boolean arr[] = sieve(1000001);
      private static ArrayList<Long> primes = new ArrayList<>();
      private static int freq[] = new int[200005];
      private static int mod = (int) (1e9 + 7);
      private static final int IMAX = 2147483647;
      private static final int IMIN = -2147483648;
      private static final long LMAX = 9223372036854775807L;
      private static final long LMIN = -9223372036854775808L;
      private static FastScanner c;
      private static PrintWriter pw;
  }