Code : Maximum Sum
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define endl "\n"
void solve(vector<long long> &a, int k) {
int n = a.size();
vector<long long> dp(n, -1);
dp[0] = a[0];
for (int i = 1; i < n; i++) {
dp[i] = max(a[i], a[i] + dp[i - 1]);
}
auto x = max(0LL, *max_element(dp.begin(), dp.end()));
auto remain = accumulate(a.begin(), a.end(), 0LL) - x;
mint ans = 0, two = 2;
ans += two.pow(k) * x;
ans += remain;
cout << ans.val() << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for (int zz = 0; zz < t; zz++) {
int n, k;
cin >> n >> k;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
solve(a, k);
}
return 0;
}