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: #include <bits/stdc++.h>
  using namespace std;
  #pragma GCC optimize("trapv")
  const long long mod = 1e9 + 7;
  const long long maxs = 1e5 + 5;
  void _print(long long t) { cerr << t; }
  void _print(int t) { cerr << t; }
  void _print(string t) { cerr << t; }
  void _print(char t) { cerr << t; }
  void _print(long double t) { cerr << t; }
  void _print(double t) { cerr << t; }
  void _print(unsigned long long t) { cerr << t; }
  template <class T, class V>
  void _print(pair<T, V> p);
  template <class T>
  void _print(vector<T> v);
  template <class T>
  void _print(set<T> v);
  template <class T, class V>
  void _print(map<T, V> v);
  template <class T>
  void _print(multiset<T> v);
  template <class T, class V>
  void _print(pair<T, V> p) {
    cerr << "{";
    _print(p.first);
    cerr << ",";
    _print(p.second);
    cerr << "}";
  }
  template <class T>
  void _print(vector<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T>
  void _print(set<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T>
  void _print(multiset<T> v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T, class V>
  void _print(map<T, V> v) {
    cerr << "[ ";
    for (auto i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  long long add(long long x, long long y) {
    long long res = x + y;
    return (res >= mod ? res - mod : res);
  }
  long long sub(long long x, long long y) {
    long long res = x - y;
    return (res <= 0 ? res + mod : res);
  }
  long long binpow(long long a, long long b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
      if (b & 1) res = res * a % mod;
      a = a * a % mod;
      b >>= 1;
    }
    return res;
  }
  long long mul(long long x, long long y) {
    long long res = x * y;
    return (res >= mod ? res % mod : res);
  }
  long long inv(long long x) { return binpow(x, mod - 2); }
  template <class T>
  long long size(T &a) {
    return a.size();
  }
  template <class T>
  void read(vector<T> &a) {
    for (long long i = 0; i < size(a); i++) cin >> a[i];
  }
  long long ceil2(long long a, long long b) {
    if (a == 0) return 0;
    return (a + b - 1) / b;
  }
  inline long long maxim(long long a, long long b) {
    if (a > b)
      return a;
    else
      return b;
  }
  inline long long minim(long long a, long long b) {
    if (a < b)
      return a;
    else
      return b;
  }
  inline bool equals(double a, double b) { return fabs(a - b) < 1e-9; }
  long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
  long long pow2(int i) { return 1LL << i; }
  int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
  int topbit(long long t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
  int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }
  int lowbit(long long a) { return a == 0 ? 64 : __builtin_ctzll(a); }
  long long allbit(long long n) { return (1LL << n) - 1; }
  int popcount(signed t) { return __builtin_popcount(t); }
  int popcount(long long t) { return __builtin_popcountll(t); }
  bool ispow2(int i) { return i && (i & -i) == i; }
  void extendgcd(long long a, long long b, long long *v) {
    if (b == 0) {
      v[0] = 1;
      v[1] = 0;
      v[2] = a;
      return;
    }
    extendgcd(b, a % b, v);
    long long x = v[1];
    v[1] = v[0] - v[1] * (a / b);
    v[0] = x;
    return;
  }
  template <class T>
  class SegmentTree {
   public:
    SegmentTree(std::vector<T> data, T value, T (*combine)(T obj1, T obj2));
    SegmentTree(T ar[], int n, T value, T (*combine)(T obj1, T obj2));
    T query(int l, int r);
    void update(int idx, T val);
  
   private:
    T *tree;
    void buildTree(std::vector<T> data);
    int segTreeSize;
    T valueForExtraNodes;
    T (*combine)(T obj1, T obj2);
    int calculateSize(int n);
    T queryHelper(int l, int r, int st, int ed, int node);
  };
  template <class T>
  SegmentTree<T>::SegmentTree(std::vector<T> data, T value,
                              T (*combine)(T obj1, T obj2)) {
    this->combine = combine;
    valueForExtraNodes = value;
    segTreeSize = calculateSize(data.size());
    buildTree(data);
  }
  template <class T>
  SegmentTree<T>::SegmentTree(T ar[], int n, T value,
                              T (*combine)(T obj1, T obj2)) {
    this->combine = combine;
    valueForExtraNodes = value;
    segTreeSize = calculateSize(n);
    std::vector<T> data;
    for (int i = 0; i < n; i++) data.push_back(ar[i]);
    buildTree(data);
  }
  template <class T>
  int SegmentTree<T>::calculateSize(int n) {
    int pow2 = 1;
    while (pow2 < n) {
      pow2 = pow2 << 1;
    }
    return 2 * pow2 - 1;
  }
  template <class T>
  T SegmentTree<T>::query(int l, int r) {
    int st = 0, ed = segTreeSize / 2;
    return queryHelper(l, r, st, ed, 0);
  }
  template <class T>
  T SegmentTree<T>::queryHelper(int l, int r, int st, int ed, int node) {
    if ((r < st) || (l > ed) || (l > r)) return valueForExtraNodes;
    if (st >= l && ed <= r) return tree[node];
    T leftVal = queryHelper(l, r, st, (st + ed) / 2, (2 * node + 1));
    T rightVal = queryHelper(l, r, (st + ed) / 2 + 1, ed, (2 * node + 2));
    return combine(leftVal, rightVal);
  }
  template <class T>
  void SegmentTree<T>::buildTree(std::vector<T> data) {
    int n = data.size();
    tree = new T[segTreeSize];
    int extraNodes = (segTreeSize / 2 + 1) - n;
    for (int i = segTreeSize - 1; i >= 0; i--) {
      if (extraNodes > 0) {
        tree[i] = valueForExtraNodes;
        extraNodes--;
      } else if (n > 0) {
        tree[i] = data[n - 1];
        n--;
      } else
        tree[i] = combine(tree[(2 * i + 1)], tree[(2 * i + 2)]);
    }
  }
  template <class T>
  void SegmentTree<T>::update(int idx, T val) {
    int segTreeIdx = (segTreeSize / 2) + idx;
    tree[segTreeIdx] = val;
    while (((segTreeIdx - 1) / 2) >= 0) {
      segTreeIdx = ((segTreeIdx - 1) / 2);
      if ((2 * segTreeIdx + 2) < segTreeSize)
        tree[segTreeIdx] =
            combine(tree[(2 * segTreeIdx + 1)], tree[(2 * segTreeIdx + 2)]);
      if (segTreeIdx == 0) break;
    }
  }
  vector<long long> primes(long long n) {
    bool prime[n + 1];
    vector<long long> p;
    fill_n(prime, n + 1, true);
    for (int i = 2; i * i <= n; i++) {
      if (prime[i] == true) {
        for (int j = i * i; j <= n; j += i) {
          prime[j] = false;
        }
      }
    }
    for (int j = 2; j <= n; j++) {
      if (prime[j]) p.push_back(j);
    }
    return p;
  }
  const int N = 1000007;
  int phi[N + 1];
  void etf() {
    int n = N;
    phi[0] = 0;
    phi[1] = 1;
    for (int i = 2; i <= n; i++) phi[i] = i;
    for (int i = 2; i <= n; i++) {
      if (phi[i] == i) {
        for (int j = i; j <= n; j += i) phi[j] -= phi[j] / i;
      }
    }
  }
  vector<vector<int>> f(N);
  void factors() {
    for (int i = 1; i < N; i++) {
      for (int j = i; j < N; j += i) {
        f[j].push_back(i);
      }
    }
  }
  vector<long long> prime_factors(long long n) {
    vector<long long> p;
    for (long long i = 2; i * i <= n; i++) {
      while (n % i == 0) {
        p.push_back(i);
        n /= i;
      }
    }
    if (n > 1) {
      p.push_back(n);
    }
    return p;
  }
  int modInverse(int a, int m) {
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1) return 0;
    while (a > 1) {
      int q = a / m;
      int t = m;
      m = a % m, a = t;
      t = y;
      y = x - q * y;
      x = t;
    }
    if (x < 0) x += m0;
    return x;
  }
  long long fact[200010];
  void compute_fact(long long modVal) {
    fact[0] = 1;
    for (int i = 1; i <= 200004; i++) {
      fact[i] = (fact[i - 1] * i) % modVal;
    }
  }
  long long ncr_mod(long long n, long long r, long long modVal) {
    if (r == 0 || n == r) return 1;
    if (n < r) return 0;
    return (((fact[n] * modInverse(fact[r], modVal)) % modVal) *
            modInverse(fact[n - r], modVal)) %
           modVal;
  }
  unsigned long long findPreviousPowerOf2(unsigned long long n) {
    if (n == 1) return 1;
    return 1ULL << (int)log2(n);
  }
  long long calprod(vector<long long> r) {
    long long res = 1;
    for (auto p : r) {
      res *= p;
    }
    return res;
  }
  int psq(int n) {
    if (sqrt(n) - floor(sqrt(n)) == 0) {
      return 1;
    }
    if (n <= 3) {
      return n;
    }
    int res = n;
    for (int i = 1; i <= n; i++) {
      int temp = i * i;
      if (temp > n)
        break;
      else
        res = min(res, 1 + psq(n - temp));
    }
    return res;
  }
  void solve() {
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> ne, po;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] < 0)
        ne.push_back(-a[i]);
      else
        po.push_back((a[i]));
    }
    sort((po).begin(), (po).end());
    sort((ne).begin(), (ne).end());
    long long ps = po.size();
    long long ns = ne.size();
    long long ans = 0;
    for (long long i = ps - 1; i >= 0; i -= k) {
      ans += 2 * po[i];
    }
    for (long long i = ns - 1; i >= 0; i -= k) {
      ans += 2 * ne[i];
    }
    long long mx = -1;
    if (ps > 0) {
      mx = max(mx, po[ps - 1]);
    }
    if (ns > 0) {
      mx = max(mx, ne[ns - 1]);
    }
    ans -= mx;
    cout << ans << "\n";
  }
  int main() {
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cout << setprecision(6) << fixed;
    int t;
    cin >> t;
    while (t--) {
      solve();
    }
    return 0;
  }
  