#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, i, k, p, q, j, m, x, sum;
  cin >> t;
  while (t--) {
    cin >> n >> q;
    sum = 0;
    long long int a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    if (n == 1) {
      cout << 1 << endl;
      continue;
    }
    vector<long long int> v;
    bool flag = true;
    if (a[0] > a[1]) {
      v.push_back(a[0]);
      flag = false;
    }
    for (i = 1; i < n; i++) {
      if (flag == false) {
        if (a[i] > a[i - 1]) {
          v.push_back(a[i - 1]);
          flag = true;
        }
      } else {
        if (a[i] < a[i - 1]) {
          v.push_back(a[i - 1]);
          flag = false;
        }
      }
    }
    v.push_back(a[n - 1]);
    if (v.size() % 2 == 0) v.pop_back();
    x = 0;
    for (auto it : v) {
      if (x % 2) {
        sum -= it;
        x++;
      } else {
        sum += it;
        x++;
      }
    }
    cout << sum << endl;
  }
}
