#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans = -LLONG_MAX;
void rec(vector<int> &a, const vector<int> &x, const int &n, int j, const int &m){
    if (j == m){
        int c = 0;
        for (int &i : a){
            c += i;
        }
        ans = max(ans, c);
        return;
    }
    for (int i = 0; i < n; ++i){
        int o = a[i];
        a[i] = x[j] - a[i];
        ++j;
        rec(a, x, n, j, m);
        --j;
        a[i] = o;
    }
}
void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int &i : x){
        cin >> i;
    }
    vector<int> a(n);
    int k = 0;
    rec(a, x, n, k, m);
    cout << ans << "\n";
    ans = -LLONG_MAX;
    if (m > n) {
        cout << x[0] * (n - 1) + (long long) (1 - (((m - n) % n) % 2)) * x[0] << "\n";
    }
    else{
        cout << x[0] * m << "\n";
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int nerpa; cin >> nerpa;
    while(nerpa--){
        solve();
    }
}
