#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    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 x1 = A[0];
    int ch = 0;
    int x2;
    for (int i = 1; i < n; i++) {
      if (A[i] >= A[i - 1] && ch == 0) {
        x1 = A[i];
        continue;
      }
      if (A[i] <= A[i - 1] && ch == 1) {
        x2 = A[i];
        continue;
      }
      if (ch == 0 && A[i] < A[i - 1]) {
        ans += A[i - 1];
        ch = 1;
      } else if (ch == 1 && A[i] > A[i - 1]) {
        ans -= A[i - 1];
        ch = 0;
      }
    }
    if (n >= 2 && A[n - 1] >= A[n - 2] && ch == 0) {
      ans += A[n - 1];
    }
    if (n == 1) {
      ans = A[0];
    }
    cout << ans << endl;
  }
  return 0;
}
