#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
long long a[N];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) cin >> a[i];
    int pre = a[0];
    int ind = 0;
    long long ans = 0;
    while (ind < n) {
      while (ind < n && pre <= a[ind]) {
        pre = a[ind++];
      }
      ans += pre;
      while (ind < n && pre >= a[ind]) {
        pre = a[ind++];
      }
      if (ind == n) break;
      ans -= pre;
    }
    cout << ans << endl;
  }
  return 0;
}
