#include <bits/stdc++.h>
using namespace std;
int 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 a[n], i, ok = 0, ok2 = 0, sum = 0;
    vector<long long> v;
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++) {
      if (i == n - 1) {
        v.push_back(a[i]);
        break;
      }
      if (ok == 0 && a[i] < a[i + 1])
        continue;
      else if (ok == 0 && a[i] > a[i + 1]) {
        ok = 1;
        ok2 = 1;
        v.push_back(a[i]);
        continue;
      }
      if (ok2 == 0 && a[i] > a[i + 1]) {
        v.push_back(a[i]);
        ok2 = 1;
        continue;
      }
      if (ok2 == 1 && a[i] < a[i + 1]) {
        v.push_back(a[i]);
        ok2 = 0;
      }
    }
    for (i = 0; i < v.size(); i++) {
      if (i % 2 == 0)
        sum += v[i];
      else
        sum -= v[i];
    }
    if (v.size() % 2 == 0) sum += v[v.size() - 1];
    cout << sum << endl;
  }
}
