#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1e9 + 7;
void solve(){
int n, k, l;
cin >> n >> k >> l;
queue<int> q;
int t = 0;
for(int i = 0; i < n; i++){
int x;
cin >> x;
q.push(x);
}
int prev = INT_MIN / 3;
int dist = 0;
while(dist < l && q.size()){
if(dist - prev < k){
dist += k;
continue;
}
int x = q.front();
q.pop();
if(x >= dist){
if(x - t <= dist){
prev = dist;
dist += k;
}else{
int rem = (x - t) - dist + 1;
t += rem;
prev = dist;
dist += k;
}
}else{
x += t;
x = min(x, dist);
if(dist - x < k){
dist += k;
}
prev = x;
}
}
if(dist < l){
if(dist - prev < k){
int tmp = k - (dist - prev) + 1;
dist += k;
t += tmp;
prev += t;
}else{
int tmp = (dist - prev) - k + 1;
t += tmp;
prev += t;
dist += k;
}
}
if(dist < l){
int g = ceil(1.0 * (l - dist) / k);
t += g * k;
}
cout << 2 * t << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7Cgp2b2lkIHNvbHZlKCl7CglpbnQgbiwgaywgbDsKCWNpbiA+PiBuID4+IGsgPj4gbDsKCQoJcXVldWU8aW50PiBxOwoJCglpbnQgdCA9IDA7CgkKCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewoJCWludCB4OwoJCWNpbiA+PiB4OwoJCXEucHVzaCh4KTsKCX0KCQoJaW50IHByZXYgPSBJTlRfTUlOIC8gMzsKCQoJaW50IGRpc3QgPSAwOwoJCgl3aGlsZShkaXN0IDwgbCAmJiBxLnNpemUoKSl7CgkJaWYoZGlzdCAtIHByZXYgPCBrKXsKCQkJZGlzdCArPSBrOwoJCQljb250aW51ZTsKCQl9C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