#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, q;
  scanf(" %d %d", &n, &q);
  vector<int> A(n);
  for (int i = 0; i < n; ++i) scanf(" %d", &A[i]);
  long long res = 0;
  bool up = true;
  int prev = 0;
  for (int i = 0; i < n; ++i) {
    if (i && A[i - 1] > A[i]) {
      if (up) {
        res += (A[i - 1] - prev);
      }
      up = false;
      prev = A[i];
    } else {
      up = true;
    }
  }
  if (up) res += (A[n - 1] - prev);
  cout << res << '\n';
}
int main() {
  int t;
  scanf(" %d", &t);
  while (t--) {
    solve();
  }
}
