#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
long long a[N];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    int q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long ans = 0;
    int f = 1;
    a[n] = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] > a[i + 1] && f == 1) {
        ans += a[i];
        f = 0;
      } else if (f == 0) {
        if (a[i] < a[i + 1]) {
          ans -= a[i];
          f = 1;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
