#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t != 0) {
    int n, q;
    cin >> n >> q;
    int arr[n + 2];
    arr[0] = 0;
    arr[n + 1] = 0;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i];
    }
    int incr = 1;
    long long int ans = 0;
    int x = 0;
    while (1) {
      if (incr == 1) {
        while (arr[x] < arr[x + 1]) {
          x++;
        }
        ans = ans + arr[x];
        incr = 0;
      } else {
        while (x + 1 <= n + 1 && arr[x] > arr[x + 1]) {
          x++;
        }
        ans = ans - arr[x];
        if (x == n + 1) {
          break;
        }
        incr = 1;
      }
    }
    cout << ans << "\n";
    t--;
  }
  return 0;
}
