#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int a[N];
struct TopOrBot {
  int num, pos;
  bool operator<(const TopOrBot x) const { return pos < x.pos; }
} q[N];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
    }
    if (n == 1) {
      cout << a[1] << endl;
      continue;
    }
    int cnt = 0;
    long long ans = 0;
    a[n + 1] = -N;
    a[0] = -N;
    for (int i = 1; i <= n; ++i) {
      if (a[i] >= a[i - 1] && a[i] > a[i + 1]) {
        q[++cnt].num = a[i];
        q[cnt].pos = i;
      } else if (a[i] < a[i - 1] && a[i] <= a[i + 1]) {
        q[++cnt].num = a[i];
        q[cnt].pos = i;
      }
    }
    sort(q + 1, q + cnt + 1);
    for (int i = 1; i <= cnt; ++i) {
      if (i % 2 == 1)
        ans += q[i].num;
      else
        ans -= q[i].num;
    }
    cout << ans << endl;
  }
  return 0;
}
