#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long mpow(long long a, long long b) {
  long long r = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) r = r * a % 1000000007;
    a = a * a % 1000000007;
  }
  return r;
}
const long long N = 3e5 + 1;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, q;
    cin >> n >> q;
    long long v[N];
    for (long long i = 1; i <= n; i++) cin >> v[i];
    v[0] = -1;
    v[n + 1] = -1;
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      if (v[i] > v[i - 1] and v[i] > v[i + 1])
        ans += v[i];
      else if (v[i] < v[i - 1] and v[i] < v[i + 1])
        ans -= v[i];
    }
    cout << ans << '\n';
  }
  return 0;
}
