#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, q, arr[300000], sum = 0, c = 0;
  cin >> t;
  while (t--) {
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    arr[n] = -1;
    for (int i = 0; i < n; i++) {
      if (c % 2 == 0) {
        if (arr[i] > arr[i + 1]) {
          sum += arr[i];
          c++;
        }
      } else {
        if (arr[i] < arr[i + 1]) {
          sum -= arr[i];
          c++;
        }
      }
    }
    cout << sum << '\n';
    sum = 0;
    c = 0;
  }
}
