#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int> > g;
vector<long long int> vis, par, ans, ans2;
void solve() {
  long long int i, j, k, x, n, c = 0, y, ans = 0, q;
  cin >> n >> q;
  map<long long int, long long int> m;
  vector<long long int> a(n);
  long long int dp[n][3];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = a[0];
  for (i = 1; i < n; i++) {
    dp[i][0] = max(dp[i - 1][0], max(dp[i - 1][1], dp[i - 1][2]));
    dp[i][1] = max(dp[i - 1][1], dp[i - 1][2] - a[i]);
    dp[i][2] = max(a[i] + dp[i - 1][1], dp[i - 1][2]);
  }
  i = n - 1;
  ans = max(dp[i][0], max(dp[i][1], dp[i][2]));
  cout << ans;
}
int main() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
