#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int tks = 0; tks < t; ++tks) {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      int tmp;
      cin >> tmp;
      a[i] = tmp;
    }
    stack<int> stk;
    bool fM = true;
    long long int rtn = 0;
    for (int i = 0; i < n; ++i) {
      if (stk.empty()) {
        stk.push(a[i]);
      } else {
        if (fM) {
          if (a[i] >= stk.top()) {
            stk.pop();
            stk.push(a[i]);
          } else {
            fM = false;
            rtn += stk.top();
            stk.pop();
            stk.push(a[i]);
          }
        } else {
          if (a[i] <= stk.top()) {
            stk.pop();
            stk.push(a[i]);
          } else {
            fM = true;
            rtn -= stk.top();
            stk.pop();
            stk.push(a[i]);
          }
        }
      }
    }
    if (fM && !stk.empty()) {
      rtn += stk.top();
    }
    cout << rtn << '\n';
  }
}
