#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, q;
    cin >> n >> q;
    vector<long long int> a(n);
    for (long long int i = 0; i < n; i++) cin >> a[i];
    long long int curr = a[0];
    long long int flag = 0;
    long long int ans = 0;
    for (long long int i = 1; i < n; i++) {
      if (flag == 0) {
        if (a[i] > a[i - 1]) {
          curr = a[i];
        } else {
          ans += curr;
          flag = 1;
          curr = a[i];
        }
      } else {
        if (a[i] < a[i - 1]) {
          curr = a[i];
        } else {
          ans -= curr;
          flag = 0;
          curr = a[i];
        }
      }
    }
    if (flag == 0) {
      ans += a[n - 1];
    }
    cout << ans << endl;
  }
  return 0;
}
