#include <bits/stdc++.h>
using namespace std;
int solve() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int ans = 0;
  int mx = 10000000, mn = -1;
  a.push_back(mn);
  a.push_back(mx);
  vector<int> s;
  int i = 0;
  while (true) {
    while (a[i] <= a[i + 1]) {
      i++;
    }
    if (a[i + 1] == -1) {
      s.push_back(a[i]);
      break;
    }
    s.push_back(a[i]);
    i++;
    while (a[i] >= a[i + 1]) {
      i++;
    }
    if (a[i + 1] == mx) {
      break;
    }
    s.push_back(a[i]);
    i++;
  }
  int gh = s.size();
  for (int i = 0; i < gh; i++) {
    if (i % 2 == 0)
      ans += s[i];
    else
      ans -= s[i];
  }
  cout << ans << "\n";
  return 0;
}
int main() {
  int test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
