#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct Node {
    int sum;
    Node (int sum): sum(sum) {}
    Node () {}
};

struct Segment_tree {
    int n;
    vector<Node> t;

    //void insert
};


signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        vector<int> vec(m);
        for (auto &i: vec) cin >> i;
        int col = m;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (col > 0) {
                if (i == n - 1 && col % 2 == 0) break;
                ans += vec[0];
            }
            else{
                break;
            }
            col--;
        }
        cout << ans << '\n';
    }

}
