#include void func (int n, int prev_flag, long long tmp, long long w_all, long long *w, long long *fib, long long *ans) { if (n <= 0) { if (tmp > *ans) { *ans = tmp; } return; } if (tmp+fib[n+1]-2LL <= *ans) { return; } n--; if (w[n] <= w_all) { func(n, 1, tmp+fib[n], w_all-w[n], w, fib, ans); return; } if (prev_flag > 0 && n > 0 && w[n]+w[n-1] < w[n+1] && w[n-1] > w_all) { func(n, 1, tmp-fib[n+1]+fib[n], w_all+w[n+1]-w[n], w, fib, ans); return; } func(n, 0, tmp, w_all, w, fib, ans); if (prev_flag > 0 && w[n] < w[n+1]) { func(n, 1, tmp-fib[n+1]+fib[n], w_all+w[n+1]-w[n], w, fib, ans); } return; } int main () { int t = 0; int n = 0; long long w_all = 0LL; long long w[75] = {}; int res = 0; long long fib[77] = {}; fib[0] = 1LL; fib[1] = 2LL; for (int i = 2; i < 77; i++) { fib[i] = fib[i-1]+fib[i-2]; } res = scanf("%d", &t); while (t > 0) { long long ans = 0LL; res = scanf("%d", &n); res = scanf("%lld", &w_all); for (int i = 0; i < n; i++) { res = scanf("%lld", w+i); } func(n, 0, 0LL, w_all, w, fib, &ans); printf("%lld\n", ans); t--; } return 0; }