#include <bits/stdc++.h>
using namespace std;
const int NMAX = 300005;
int N, Q;
long long a[NMAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tests;
  cin >> tests;
  while (tests-- > 0) {
    cin >> N >> Q;
    for (int i = 1; i <= N; ++i) cin >> a[i];
    int op = 0, p = 1;
    long long answer = 0;
    int last = 0;
    while (p <= N) {
      if (op == 0) {
        while (p < N && a[p] <= a[p + 1]) ++p;
        answer += a[p];
        ++p;
      } else {
        while (p < N && a[p] >= a[p + 1]) ++p;
        answer -= a[p];
        last = a[p];
        ++p;
      }
      op ^= 1;
    }
    if (op == 0) answer += last;
    cout << answer << "\n";
  }
  return 0;
}
