#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using namespace std;
const double EPS = 1e-6;
int t, n, q, arr[300005];
int main() {
  scanf("%d", &t);
  while (t--) {
    long long mx = 0;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++) {
      scanf("%d", &arr[i]);
      mx = max(mx, (long long)arr[i]);
    }
    int e = 1e9;
    long long ans = 0;
    bool fl = 1;
    for (int i = 1; i < n; i++) {
      if (arr[i - 1] > arr[i] && fl) {
        if (arr[i - 1] != e) ans += arr[i - 1];
        fl = 0;
      } else if (arr[i] > arr[i - 1] && !fl) {
        e = arr[i];
        ans -= arr[i - 1];
        ans += arr[i];
        fl = 1;
      } else if (arr[i] > e && fl) {
        ans -= e;
        ans += arr[i];
        e = arr[i];
      }
    }
    cout << max(ans, mx) << '\n';
  }
  return 0;
}
