#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, temp;
    cin >> n;
    long long q;
    cin >> q;
    vector<long long> a;
    for (long long i = 0; i < n; i++) {
      cin >> temp;
      a.push_back(temp);
    }
    long long flag1 = 1;
    long long second = 0;
    if (n == 1) {
      cout << a[0] << "\n";
      continue;
    }
    for (long long i = 1; i < n; i++) {
      if (a[i - 1] > a[i] && flag1) second += a[i - 1], flag1 = 0;
      if (a[i - 1] < a[i] && !flag1) second -= a[i - 1], flag1 = 1;
    }
    if (a[n - 1] > a[n - 2]) second += a[n - 1];
    cout << second << "\n";
  }
  return 0;
}
