#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
using namespace std;
const int N = 1e6 + 10;
int t, n, q;
int a[N];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n), scanf("%d", &q);
    int mmin = n, mmax = 0;
    a[0] = a[n + 1] = 0;
    for (register int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
      mmax = max(mmax, a[i]);
    }
    if (n == 2) {
      cout << mmax << endl;
      continue;
    }
    long long res = 0;
    for (register int i = 1; i <= n; ++i) {
      if (a[i] > a[i - 1] && a[i] > a[i + 1]) res += a[i];
      if (a[i] < a[i - 1] && a[i] < a[i + 1]) res -= a[i];
    }
    cout << res << endl;
  }
  return 0;
}
