text: #include <bits/stdc++.h>
  using namespace std;
  
  void solve() {
  	int n, k; 
  	cin >> n >> k;
  	vector<int> a(n), pos, neg;
  	for (int i = 0; i < n; i++) {
  		cin >> a[i];
  		if (a[i] > 0) pos.push_back(a[i]);
  		else neg.push_back(-a[i]);
  	}
  	sort(pos.begin(), pos.end());
  	sort(neg.begin(), neg.end());
  	long long ans = 0, x = pos.size(), y = neg.size();
  	for (int i = x - 1; i >= 0; i -= k) ans += pos[i] * 2;
  	for (int i = y - 1; i >= 0; i -= k) ans += neg[i] * 2;
  	if (x > 0 && y > 0) ans -= max(pos[x - 1], neg[y - 1]);
  	else ans -= x > 0 ? pos[x - 1] : neg[y - 1];
  	cout << ans << endl;
  }
   
  int main() {
  	ios_base::sync_with_stdio(false), cin.tie(nullptr);
   
   	int T; cin >> T;
   	while(T--) solve();
   	// solve();
  	return 0;
  }
  
  