// tch1cherin GM!
#include <bits/stdc++.h>
using namespace std;

constexpr long long INF = 1e18;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int &value : x) {
      cin >> value;
    }
    reverse(x.begin(), x.end());
    vector<long long> dp(n + 1, -INF);
    dp[0] = 0;
    for (int value : x) {
      vector<long long> ndp(n + 1, -INF);
      for (int i = 0; i < n; i++) {
        ndp[i] = dp[i + 1];
      }
      for (int i = 0; i < n; i++) {
        ndp[i + 1] = max(ndp[i + 1], dp[i] + value);
      }
      dp = ndp;
    }
    long long total = accumulate(x.begin(), x.end(), 0LL);
    long long max_dp = *max_element(dp.begin(), dp.end());
    cout << 2 * max_dp - total << "\n";
  }
}
