#include <bits/stdc++.h>
using namespace std;
stringstream ss;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
const int maxn = 3e5 + 5;
long long d[maxn];
long long dp[maxn][4];
int t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    int n, q;
    cin >> n >> q;
    for (int i = (0); i < (n); ++i) cin >> d[i];
    dp[0][0] = 0;
    dp[0][1] = d[0];
    dp[0][2] = 0;
    dp[0][3] = -1e5;
    for (int i = (1); i < (n); ++i) {
      dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
      dp[i][1] = max(dp[i - 1][2] + d[i], dp[i - 1][3] + d[i]);
      dp[i][2] = max(dp[i - 1][2], dp[i - 1][3]);
      dp[i][3] = max(dp[i - 1][0] - d[i], dp[i - 1][1] - d[i]);
    }
    cout << max(dp[n - 1][0],
                max(dp[n - 1][1], max(dp[n - 1][2], dp[n - 1][3])))
         << endl;
  }
  return 0;
}
