#include <bits/stdc++.h>
const long long int mod = 998244353;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int a[300005], n, cnt, i, sum, sum1 = 0, q, l;
  long long int t;
  cin >> t;
  while (t--) {
    cin >> n >> q;
    for (i = 0; i < n; i++) cin >> a[i];
    a[n] = 0;
    l = 0;
    sum1 = 0;
    while (a[l] < a[l + 1] && l < n) l++;
    sum = a[l];
    cnt = 0;
    for (i = l + 1; i < n; i++) {
      if (a[i] > a[i + 1]) {
        if (cnt % 2 == 1) {
          sum1 += a[i];
          cnt = 0;
        }
      } else {
        if (cnt % 2 == 0) {
          sum1 -= a[i];
          cnt = 1;
        }
      }
      if (cnt == 0 && sum1 > 0) {
        sum += sum1;
        sum1 = 0;
      }
    }
    cout << sum << "\n";
  }
  return 0;
}
