#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, q;
  cin >> n >> q;
  long long A[n];
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
  }
  vector<long long> b;
  long long co = 1;
  for (long long i = 0; i < n; i++) {
    if (co == 1) {
      if (i == n - 1) {
        b.push_back(A[i]);
      } else {
        if (A[i + 1] < A[i]) {
          b.push_back(A[i]);
          co = 0;
        }
      }
    } else if (co == 0) {
      if (i != n - 1) {
        if (A[i + 1] > A[i]) {
          b.push_back(A[i]);
          co = 1;
        }
      }
    }
  }
  long long co1 = 0;
  long long sum = 0;
  for (long long i = 0; i < b.size(); i++) {
    if (co1 == 0) {
      co1 = 1;
      sum = sum + b[i];
    } else {
      co1 = 0;
      sum = sum - b[i];
    }
  }
  if (b.size() % 2 == 0) {
    sum = sum + b[b.size() - 1];
  }
  cout << sum << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
